I’m currently working on a piece of software that has three 2-d display regions, as well as the default 3d view. Following the manual and this discussion here: Mouse events ignored in display region I’ve created the additional display regions, and set the default mouseWatcher’s display region to be exclusive to the default display region. Then, I create a mouseWatcher for each display region parented to the default mouseWatcher’s parent, and I attach a button thrower to each of those.
Despite using mouseWatcher’s
set_down_pattern() function and such, base.messenger.toggleVerbose() shows that all mouseWatchers throw the default event names, and functions bound to my own event patterns never throw.
also, mouse button “up” events seem to be thrown three times.
Could anyone point me in the right direction?
edit: I forgot to mention that I also tried the
set_frame() function to see if that would help.
I think that what might be called for is a separate “ButtonThrower”-object attached to your MouseWatcher. ButtonThrowers can assign a “prefix” to their events, thus allowing you to make them unique.
Something like this:
# Create our MouseWatcher as per usual
# I'm here skipping over the attaching of the watcher;
# presume that that happens as in your code
self.watcher = MouseWatcher("myWatcher")
# Now, create a button-thrower, and give it a prefix
self.thrower = ButtonThrower("myThrower")
self.thrower.prefix = "kittens_"
# Add said button-thrower to the watcher
# And now we can accept events using that prefix!
# For example, accepting the "arrow_up" event:
That said, I’m not sure of why setting the event-pattern in the MouseWatcher doesn’t work–from a quick look at the manual, it does seem that it should.
Ah, so the buttonThrower is supposed to be a child of the pandaNode after all? The form post I referenced said it should be parented to the nodepath.
It is strange that setting the event-pattern didn’t work… But setting the buttonThrower’s prefix did! The only thing I’ve yet to figure out is if I can suppress button-up events in inactive regions… For some reason, only the active region throws a “down” event but all mouseWatchers throw “up” events…
Thank you very much!
I’m glad to have helped!
I think that I’ve seen a similar issue, myself, if in a different context. I really don’t know what causes it–it seems like it might be either an engine bug or a non-intuitive but expected behaviour…
Perhaps it’s worth filing an entry for it in Panda’s GitHub issue tracker?