I have multiple display regions. Different ones are under the mouse at different times. Unfortunately they overlap.
Is there a handy function to determine which DR is under the mouse at any given time? Either the one with the highest sort value or the entire list would be OK.
I don’t think there’s anything built-in to determine that. But you could examine the DR coordinates yourself and write a simple program to determine it; or, you could create a series of MouseWatcherRegions that correspond to the DisplayRegions, and let Panda do the math each frame for you.
MouseWatcherRegions were originally devised to implement onscreen gui systems such as DirectGui; each MWR is a rectangular region onscreen that Panda can automatically detect the mouse’s presence over. When they overlap, you can get the topmost. It will also generate events at transition points, as the mouse moves around the screen; and if you listen to the events, you can keep track of the entire set of MWR’s under the mouse.
The MouseWatcher is the class that monitors the set of MWR’s, and you can get the default MouseWatcher in base.mouseWatchers[0]. Then you can call addRegion() for each region you create.
Note that the space of the MouseWatcherRegion is different than the space of a DisplayRegion. When you define a DisplayRegion, (0, 0) is the lower-left corner of the screen, and (1, 1) is the upper-right corner.
However, all mouse coordinate operations are in a different space, with (-1, -1) in the lower-left, (0, 0) in the center, and (1, 1) in the upper-right. This includes MouseWatcherRegion; you have to be sure you create your MouseWatcherRegions to reflect the space you actually intend.
The reason for this difference is historical: the DisplayRegion space was defined first, and was made to be similar to UV mapping a texture to the whole screen; but when we added the mouse coordinates later it seemed better to put (0, 0) in the center.