|Topic was automatically imported from the old Question2Answer platform.
How to detect the click outside the UI element. Say I have an ItemList which is 1/3 of the screen and appears on top of the screen in the center. I want to hide it when the user clicks on the empty space, but I can’t find a way to check if the click position intersects with the element
“but I can’t find a way to check if the click position intersects with the element”
Why? Give little more details pls.
LordViperion | 2019-02-27 23:00
I don’t know what details do you want to know. I told almost everything that it related to the question, also it is a 2D game.
jackash | 2019-02-27 23:07
I think you could use
_unhandled_input function for this… as the item list is a gui element, I think that clicking on it would do normal gui handling and the event won’t reach the
_unhandled_input function. Then, inside that function you check if event is the mouse click, and if it is you hide the item list…
p7f | 2019-02-27 23:14
Could try, but why is it that complicated, I mean why should we rely on the event not reaching some handler?
jackash | 2019-02-27 23:17
Actually, in my opinion is more complicated to detect wether you clicked specifically outside a gui element.
_unhandled_input is the way you should handle non gui events… if you wait a couple hours, may be I can do an example
p7f | 2019-02-27 23:39
(this comment is moved to an answer)
wombatstampede | 2019-02-28 16:16
That’s actually helpful, can you send it as an answer so I can choose it as a solution
jackash | 2019-02-28 17:37