Page 1 of 1

Handling mouse events on Gui with c#

Posted: 24 Feb 2019, 10:39
by digimbyte
I've searched on google for the last few days but I can't seem to find any code examples or documentation of how to handle mouse events in c#
https://www.noesisengine.com/docs/Gui.C ... ement.html

I'm interested in detecting closing panels if the user clicks on some other part of the UI or in world space
how would I attach a passive script on my UI element as some sort of event listener?
or would it be better to have it in a main mouse event script?

Re: Handling mouse events on Gui with c#

Posted: 25 Feb 2019, 16:18
by sfernandez
You can use hit testing to determine if a mouse click hit the UI or not. Take a look at this post: viewtopic.php?f=3&t=1550

Antoher option is to capture mouse (element.CaptureMouse()) when you open a panel, so all mouse events are redirected to the element, and then check against element bounds to see if user clicked outside the element.