From e8fc76747a1821c70802eaf375acc6769a48d301 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 13 May 2019 13:52:19 +0200 Subject: [PATCH] showbase: rename attachInputDevice gui=True arg to watch=True It describes more accurately what it does, which is attach the MouseWatcher to it. Though it was intended to help with GUI navigation, it can also be used for eg. polling button states. --- direct/src/showbase/ShowBase.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 5523d91a98..0dd8a05b3b 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -1679,16 +1679,18 @@ class ShowBase(DirectObject.DirectObject): return self.mouseWatcherNode.getModifierButtons().isDown( KeyboardButton.meta()) - def attachInputDevice(self, device, prefix=None, gui=False): + def attachInputDevice(self, device, prefix=None, watch=False): """ This function attaches an input device to the data graph, which will cause the device to be polled and generate events. If a prefix is given and not None, it is used to prefix events generated by this device, separated by a hyphen. - The gui argument can be set to True (as of Panda3D 1.10.3) to set up + The watch argument can be set to True (as of Panda3D 1.10.3) to set up the default MouseWatcher to receive inputs from this device, allowing - it to control user interfaces. + it to be polled via mouseWatcherNode and control user interfaces. + Setting this to True will also make it generate unprefixed events, + regardless of the specified prefix. If you call this, you should consider calling detachInputDevice when you are done with the device or when it is disconnected. @@ -1700,7 +1702,7 @@ class ShowBase(DirectObject.DirectObject): idn = self.dataRoot.attachNewNode(InputDeviceNode(device, device.name)) # Setup the button thrower to generate events for the device. - if prefix is not None or not gui: + if prefix is not None or not watch: bt = idn.attachNewNode(ButtonThrower(device.name)) if prefix is not None: bt.node().setPrefix(prefix + '-') @@ -1709,7 +1711,7 @@ class ShowBase(DirectObject.DirectObject): assert self.notify.debug("Attached input device {0} with prefix {1}".format(device, prefix)) self.__inputDeviceNodes[device] = idn - if gui: + if watch: idn.node().addChild(self.mouseWatcherNode) def detachInputDevice(self, device):