I want to monitor certain regions of the screen using MouseWatcherRegion. After fiddling with things a bit, I’ve managed to get mouseWatcherNode.getOverRegion to recognize the region that I declare.
mwr = MouseWatcherRegion( 'testsq', VBase4(-0.3, .3, -.3, .3))
base.mouseWatcherNode.addRegion( mwr )
But how I do Messenger to automatically create entry/exit messages for the custom MouseWatcherRegion like it does for the DirectGui* stuff? Right now, messenger doesn’t provide any messages when I wave the mice across my custom region.
wouldn’t you have to make a task to check to see which region the mouse is it? I dont remember any exact code but I think I did something like that for someone else before. Sorry if Im not terribly helpful
Yes, I could poll mouseWatcherNode.getOverRegion() every frame using a task, but I would prefer to have a unified system. (The DirectGui objects all use the messenger system.)
Ah, great. Thanks for the help David. Can you also show me how to properly declare a new MouseWatcherGroup?
I tried with the following simple syntax
mwg = MouseWatcherGroup()
And I received an error message that I don’t understand:
TypeError: Error Can Not Init Constant Class (MouseWatcherGroup)
Hmm, looks like we haven’t exposed the MouseWatcherGroup constructor to Python. But normally there’s no reason to create a new group; it doesn’t give you any new functionality that you don’t have already in the existing MouseWatcher object. The reason that MouseWatcherGroup exists is to support certain low-level C++ features such as the PGui system (which is the C++ implementation of DirectGui). If you’re just writing Python-level code, I’m not sure that there’s anything useful that MouseWatcherGroup gives you.