Jump to content

Hidden Popover Open/Close


This topic is 1280 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello and thank you peeking at my question... I can not seem to get my scripts to behave in a way that is expected, driving me batty!

OBJECTIVE :: Fix Popover Open button so that when clicked popover opens, and when clicked again the popover closes.

CURRENT ERROR :: At the moment when Popover button is clicked the popover opens, and then just reopens when clicked again, which is not the desired behavior.

NOTES :: To help illustrate my issue, I've attached some files.
THANK YOU kindly for your time and help! 🤠

sample_popover_open_close.png

sample_popover_open_close.fmp12

I've been able to get the highlight open/close to work outside of this demo file. But NOT when I have a "clear highlight" script trigger attached popover. I need a "clear highlight" script trigger for when User clicks anywhere other then the button and closes the popover. Record should only highlight when popover is open.

Link to comment
Share on other sites

Remove the script trigger from the popover, and instead add this to the top of the popover open script:

If[ FOODS::__pk_FOODS = FOODS::highlightGlobal ]
  Set Field[ FOODS::highlightGlobal ; "" ]
  Exit Script
End If

 

Link to comment
Share on other sites

Gottcha, Fitch!... in the working file outside this demo, I'm using the if [], and that works fine as long as the User presses the script button. But User is highly likely not to only click the button, and more likely to just randomly click elsewhere on the layout... which will cause the popover to close while leaving a highlighted state active.

I've updated the file and screenshot of script:

 

 

sample_popover_open_close_2.fmp12

Screen Shot 2020-10-18 at 7.49.01 PM.png

Edited by Dr. Evil
Link to comment
Share on other sites

On 10/18/2020 at 7:50 PM, Dr. Evil said:

randomly click elsewhere on the layout... which will cause the popover to close while leaving a highlighted state active.

You almost had it ... since you want to clear the global value (that controls the conditional formatting), you must use OOExit script trigger on the popover.  Attached is how I'd modify your example.  Of course there are other ways to approach the problem ... there are always alternatives. 😁

 

sample_popover_open_close_MOD.fmp12

Edited by LaRetta
Link to comment
Share on other sites

☺️ Thank you LaRetta!.. this functions, but still when User clicks say, the Burrito item, popup appears, if the User clicks the burrito again, it should close, but at the moment it pops back open. I'm hoping for the effect of it collapsing open when clicks, and collapse down with clicked again. 

This is normal behavior for a popover to collapse out when click, and collapse down when clicked again. BUT since it is being activated via script, the natural behavior has changed.

I apologize for my awkward type up description, i often wish some in-person work could be done.

Link to comment
Share on other sites

I don't think it's possible to have exactly what you ask for; however, there are two almost perfect workarounds.

1. Why I believe it's impossible

It is imposible because of the order in which actions happen. When a popover is open, and you click anywhere outside of the popover, two things will happen: first, the popover will close; then - and only then - the click will be executed:

  • if you clicked on the layout's background, the popover will close and the record will be committed;
  • if you clicked in a field, the popover will close and the field will be activated;
  • if you clicked on a button, the popover will close and the button will be fired.

What this means is that by the time the button's action is executed, the popover is already closed. The button has no way of telling the difference between being clicked the first time and the second time; in both scenarios, it will open the popover.

2. The workarounds

There is an exception to the rule above, and that is clicking the popover button itself. Here, clicking the button a second time will close the popover and nothing else. So the simplest way to achieve toggling the popover's state is to use the popover's button instead of your own - and compromise on the placement of the popover relative to the button: it could be upward or downward from the middle of the button or rightward/leftward from the left/right edge of the button.

The other workaround is to cancel the second part of the action by attaching an OnObjectExit script trigger to the popover:

Close Popover
Exit Script [ Result: False ]

This will make a second click on the button close the popover and nothing else - resulting in an effective toggle. However doing so has a side effect: if you click in a field, the popover will close - but the field will not be activated. Instead, the focus will pass to the popover's button (which could be hidden to minimize the effect of this).

 

Edited by comment
  • Like 1
Link to comment
Share on other sites

This topic is 1280 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.