In my current project, I’ve set the mouse-mode to “M_confined”. Unfortunately, this seems to have resulted in the mouse-cursor no longer being visible!
Specifically, it seems the issue occurs when one sets the window-properties with “setMouseMode(WindowProperties.M_confined)”, then (almost) immediately afterwards, in a second call to “base.win.requestProperties”, sets them again with the cursor hidden via “setCursorHidden(True)”. This seems to cause the cursor to disappear (as expected), and to not return after a later use of “setCursorHidden(False)”.
If there’s a gap between the first two requests for window-properties (such as if the second is run as a result of a button-press), then the issue doesn’t appear. Similarly, if they still occur one directly after another, but “setMouseMode(WindowProperties.M_confined)” is omitted, then again the issue doesn’t appear. Only if both the mouse-mode is set and the two requests for window-properties occur one directly after another does the issue show itself.
It’s not clear how “immediately” the two calls should be to cause the issue to appear.
I’m pretty confident that this worked in 1.9.
A simple program that demonstrates the issue on my end; when run, press “1”, then “2”.
from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties
class GameFramework(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.disableMouse()
self.accept("1", self.one)
self.accept("2", self.two)
def one(self):
print "One!"
wp = WindowProperties()
# Comment out this next line to cause the
# subsequent call of the method "two" to
# work as expected
wp.setMouseMode(WindowProperties.M_confined)
wp.setCursorHidden(False)
base.win.requestProperties(wp)
wp = WindowProperties()
wp.setCursorHidden(True)
base.win.requestProperties(wp)
def two(self):
print "Two!"
wp = WindowProperties()
wp.setCursorHidden(False)
base.win.requestProperties(wp)
# Let the game begin!
gameFramework = GameFramework()
gameFramework.run()
This was encountered in a custom build of 1.10, running under Ubuntu 16.04 (“Xenial”), I believe.
(As for why I’m requesting window-properties one directly after another like this, it’s a matter of program flow. As I recall: The first request is initialisation (including setting the “confined” mode). The second arises from a call to a method that is used both there and elsewhere in the program, and that happens to hide the cursor as part of its work.)