Mouseexit handle close window not working


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.

I know @dawid_styczynski had mentioned the onKeyPress event before he deleted it, but I think he’s close.

What about a mousePressed or mouseReleased event instead?

Just make the button really big? :laughing:

How close to exiting? And is this a touch screen or are they actually using a mouse?

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.

1 Like

@lrose in the middle of the container the script is on.

1 Like

@JordanCClark well if they click a button on it. Let’s say a HOA for example. I don’t want to close it as they may need the HOA open to re click.

However when they click on the main window, I want that HOA closed as they are intentionally leaving it.

@pturmel makes sense. Any good suggestions for me to try a different route?

Consider using a timer component in the popup that you reset whenever there’s any events anywhere in the window. If it times out, it closes the popup.

1 Like

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.

1 Like

@pturmel not a bad idea. I’ll have to do some research on an acceptable timeout delta.

@justinedwards.jle interesting idea. I’ll have to do some testing and play around with that idea.

1 Like

@justinedwards.jle I tired that, and couldn’t get it working.

I was however able to get it a lot more stable with InternalFrameDeactivated now it only closes when i click one button

ahhh, its because someone has a confirmation script on that button, which does cause it to loose focus.

1 Like

I was able to get it working perfectly with InternalFrameDeactivated and having it close the window

1 Like

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
1 Like

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.

1 Like