mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
adding silenceInput() and reviveInput() for global disabling of all inputs at once
This commit is contained in:
parent
87e65af730
commit
7d9121d2d4
@ -373,10 +373,12 @@ class ShowBase(DirectObject.DirectObject):
|
||||
|
||||
if self.windowType != 'none':
|
||||
self.__doStartDirect()
|
||||
|
||||
|
||||
self.__deadInputs = None
|
||||
|
||||
# Start IGLOOP
|
||||
self.restart()
|
||||
|
||||
|
||||
# add a collision traverser via pushCTrav and remove it via popCTrav
|
||||
# that way the owner of the new cTrav doesn't need to hold onto the
|
||||
# previous one in order to put it back
|
||||
@ -1177,14 +1179,13 @@ class ShowBase(DirectObject.DirectObject):
|
||||
self.dataRootNode = self.dataRoot.node()
|
||||
self.dataUnused = NodePath('dataUnused')
|
||||
|
||||
|
||||
def setupMouse(self, win):
|
||||
"""
|
||||
Creates the structures necessary to monitor the mouse input,
|
||||
using the indicated window. If the mouse has already been set
|
||||
up for a different window, those structures are deleted first.
|
||||
"""
|
||||
|
||||
self.reviveInput()
|
||||
if self.buttonThrowers != None:
|
||||
for bt in self.buttonThrowers:
|
||||
mw = bt.getParent()
|
||||
@ -1192,7 +1193,6 @@ class ShowBase(DirectObject.DirectObject):
|
||||
bt.removeNode()
|
||||
mw.removeNode()
|
||||
mk.removeNode()
|
||||
|
||||
# For each mouse/keyboard device, we create
|
||||
# - MouseAndKeyboard
|
||||
# - MouseWatcher
|
||||
@ -1692,6 +1692,26 @@ class ShowBase(DirectObject.DirectObject):
|
||||
if self.mouse2cam:
|
||||
self.mouse2cam.reparentTo(self.mouseInterface)
|
||||
|
||||
def silenceInput(self):
|
||||
"""
|
||||
This is a heavy-handed way of temporarily turning off
|
||||
all inputs. Bring them back with reviveInput().
|
||||
"""
|
||||
if not self.__deadInputs:
|
||||
self.__deadInputs = self.dataRoot.getChildren()
|
||||
self.dataRoot.removeChildren()
|
||||
|
||||
def reviveInput(self):
|
||||
"""
|
||||
Restores inputs after a previous call to silenceInput.
|
||||
"""
|
||||
if self.__deadInputs:
|
||||
self.eventMgr.doEvents()
|
||||
self.__deadInputs.reparentTo(self.dataRoot)
|
||||
self.__deadInputs = None
|
||||
self.dgTrav.traverse(base.dataRootNode)
|
||||
self.eventMgr.eventQueue.clear()
|
||||
|
||||
def setMouseOnNode(self, newNode):
|
||||
if self.mouse2cam:
|
||||
self.mouse2cam.node().setNode(newNode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user