[2.0.41] on_gui_leave is raised on sub elements

Bugs that are actually features.
User avatar
Kuxynator
Inserter
Inserter
Posts: 36
Joined: Wed Sep 23, 2020 5:02 pm
Contact:

[2.0.41] on_gui_leave is raised on sub elements

Post by Kuxynator »

I want to create a context menu that closes when the mouse leaves the area

Code: Select all

frame { name = "context_menu", direction = "vertical", raise_hover_events = true,
	flow {
		button {caption="Option 1"},
		button {caption="Option 2 long text"},
		button {caption="Option 3" }
	}

script.on_event(defines.events.on_gui_leave, function(e)
	if element  and e.element.name == "context_menu" then close(e) return end
end)
Problem:
The event is already raised when you move over the content (the buttons) and do not leave the frame at all.

Expected behavior:
as long as the mouse is within the element, on_gui_leave must not be raised.

Using Factorio 2.0.41, but the problem has probably existed for some time.

P.S.:
the forum search does not work as expected.
- seach for "on_gui_leave" shows 10000 irrelevant results.
- seach for "on_gui_leave" in topics only shows less results but none of them with "on_gui_leave".
Rseding91
Factorio Staff
Factorio Staff
Posts: 15584
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.41] on_gui_leave is raised on sub elements

Post by Rseding91 »

Thanks for the report however this is unlikely to change as this is how the generic GUI logic works since forever. gui enter/leave is specific to the element the mouse is directly over and it is not called for parents of elements the mouse is over - only the final element itself.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Not a bug”