Multiple MouseWatchers Manual Entry? [SOLVED]

So, I started messing around with display regions and I ran into some mouse picking problems because of the coordinates getting fubar. The simple solution is constraining the MouseWatcher to a given display region, but this breaks down when you want mouse events in multiple display regions.

I did some research on the forums about how to fix this, and I kept finding the same responses. I will sum them up.

  1. You could create an additional MouseWatcher for each display region.

  2. You could do some sort of math to convert the coordinates from one display region to another.

Now, in every response I saw, the same recommendations were made: Don’t do option 1, it’s too complicated. Option 2 is simple and easy.

I don’t know about everyone else, but for me, math is friggin’ hard. Figuring out the conversion of coordinate systems is no exception. So I said “balls” to the recommendations, kept researching, and found that I could do this:

myMouseWatcher = MouseWatcher
# Creates a new mouse watcher

# Gets the MouseAndKeyboard object(node?) 
# that passes mouse data into MouseWatchers, 
# and attaches my MouseWatcher to it.

# Restricts my MouseWatcher to my intended display region.

And bam. I had my own fully functional MouseWatcher created, tied to my display region, and usable.

That doesn’t seem so hard to me. Why is everyone recommending against option 1?

I don’t know. I added setDisplayRegion() exactly to support this kind of thing. Was I one of the ones advocating against it?


Yeah, you said:

On apr 03, 2010 in this post:
[url]Oh my god!]

Maybe you forgot about it or I misread the thread or something? I don’t know. The fact that you’re now saying “I don’t know”, combined with the fact that you are THE go-to guy on Panda3D, means that I’m not wrong in my thinking. That’s good enough for me.

Thanks for the reaffirmation, Drwr. In case you haven’t figured it out already, I consider you the authority on Panda3D, and I really appreciate your contributions on these forums.

I completely forgot the main reason I created this topic. Should I throw a quick page on making multiple MouseWatchers for multiple display regions in the manual?

If so, how would I do that? In fact, somebody please answer this question regardless. I need to add the page on garbage collection I wrote up a while back, too.

Sure, feel free to make such a page. I think the reason I was advocating against this approach in the quoted thread was that it requires at least some understanding of the data graph and how events are processed, which many newcomers to Panda find completely mystifying; and also if you want more than just a clickable MouseWatcherRegion, if you want to track button events for instance, or use full-strength DirectGui objects, you do need to do a bit more work, which is again not obvious to a newcomer.

So it comes down to whether it’s easier to learn the appropriate systems in Panda, or to do the necessary math yourself, which might be less work in the short term if you’re comfortable with the math and you don’t already understand the appropriate systems in Panda. Of course, every situation is different. :slight_smile:

Anyone can contribute to the manual; it’s just a wiki with a secret login button. Read this page for guidance, and then log in at this url. Ignore the error message and go back to the page you want to edit; you’re logged in.


I see where you were coming from.

I’ll see what I can do about the manual entries.

I’m having trouble logging in to the manual. It’s telling me I have cookies disabled, but I have them enabled. This happened in both Chrome and Internet Explorer.

Ignore the error message, it’s borked. But you’re logged on anyway. When you then click on a manual page, you’ll see a new row of links across the bottom, including “Edit”.


Alright, I added a page to the manual for making mouse watchers for specific display regions.

Thanks! :slight_smile: