DirectGUI: Detect hover without "bind"?

I have a perhaps slightly odd question:

How might I detect whether the mouse is over a DirectFrame (or other DirectGUI object–I’m open to changing which one I use), without using “bind” to detect events?

MouseWatcherRegions seem as though they might provide one potential solution, but my gui objects are kept in a DirectScrolledRegion, meaning that their position might change, and some might be off-screen; I could update the regions manually, but at that point I might as well just check the mouse-coordinates at the same time and drop the MouseWatcherRegions, it would seem.

To explain, I have a project in which I want to detect and respond to various events related to a set of DirectGUI elements: I want to know when the mouse enters or leaves them, and want to respond to “action” -down and -up events. These “action” events would by default be mouse events–meaning that I could potentially just use “bind” to detect them–but I’m allowing my users to redefine their key-mappings, including the “action” key; I could make this particular system (an inventory) an exception, having it only respond to the mouse, but would prefer not to: I may think that using “k” for “action” is a somewhat silly idea, but if a player wants to have it so, I’d prefer to keep my in-game interface consistent.

(In all fairness the menus would still respond to the mouse, rather than the “action” key, which might give some weight to the idea of making an exception to interface consistency here, but I’d like to at least try to get this working as intended.)

You can use this DGG.WITHOUT and DGG.WITHIN events to detect if the mouse pointer is over a given dgui element e.g.:

frame.bind(DGG.WITHOUT, hover_command,[False])  
frame.bind(DGG.WITHIN, hover_command, [True])

The hover_command can update a variable that then is used by the ‘action’ command (be it ‘mouse1’ or ‘k’ or whatever), but be sure to reset the variable when the mouse is out of the window or the window looses focus.

Thank you. :slight_smile:

I don’t think that the DGG events are what I’m looking for, since (as mentioned above) I’m trying to avoid the use of “bind”: events bound buy that method don’t seem to be called unless I set the DirectGUI object’s state appropriately, which interferes with the more general events that I’m using for my interface.

However, having given it further thought, I will admit that there’s a decent argument for having my inventory be consistent with my menus, rather than the rest of my gameplay (while said gameplay does use the mouse, it uses it either hidden or locked to the centre of the screen; additionally, the inventory will presumably use whatever mouse cursor is used in the menus). For now, at least, I’m giving in and using “bind” for both hover-detection and mouse-button events.