I go into the popups root container and set it to close the window on the mouseexited event handler. But it closes before the mouse exits the window…
Any ideas why this is happening? I need to close the popups automatically because apparently production has thick fingers and clicking a button just doesn’t cut it.
MouseExit triggers whenever the mouse leaves the component’s input scope for any other input scope including its own children. That’s why it’s breaking for you.
The mouseExited event should work fine if you qualify it using the dimensions of the popup:
if event.x >= event.source.parent.parent.parent.size.width-20 or event.y >= event.source.parent.parent.parent.size.height-40 or event.x <= 20 or event.y <= 20:
#Put close window command here
Edit: After experimenting with this, I realized that I had forgot to include the upper and left edges. This has been corrected. I also padded the margins a little bit to improve reliability.
My guess would be that a component within the frame was touching the edge of the window and preventing the event. The following experiment illustrates this problem:
Here is a popup window that tracks and displays the mouse cursor position using the mouseMoved event handler. I have set a margin around the popup of 20 pixels, so any time the cursor travels within 20 pixels of the edge, the lower text field will display false, and if the goal is to close the window, a navigation close script would work here:
Now, if I enter the text field from the bottom while the cursor is within the margines, the mouse cursor stops being tracked, and if it approaches the margin and leaves the popup, the bool will not change state, and the window close script will not fire:
As you can see, the only way for the mouse script to work, is if the margins around the popup are not covered by other components:
Therefore, to be successful using a mouse exited script with boundary constraints on the container itself, you would have to make sure that none of the internal components were touching the edge, and you would have to set the minimum size parameters of the popup to prevent users from sizing the window in such a way that would cause a component to overlap the edge.
Here is the code I used, in case you want to experiment with this yourself:
e = event
margin = 20
x2 = e.source.width - margin
y2 = e.source.height - margin
withinMargines = "False"
if e.x > margin and e.y > margin and e.x < x2 and e.y < y2:
withinMargines = "True"
event.source.getComponent('Text Field').text = "Current mouse coordinates: ("+str(e.x)+", "+str(e.y)+")"
event.source.getComponent('Text Field 1').text = "Curser Within Margines = "+withinMargines
Thanks, I will play around with it more. Either way the scripted popup causes issues and its hard to control where that opens. I’m working on a way to not need that which will simplify the system a lot.