I’m trying to handle two specific mouse-events, without clashing with other objects that may be handling the same events, and without DirectGUI blocking them.
To this end, I’m currently thinking to create a custom ButtonThrower to generate these events.
Creating a ButtonThrower isn’t too difficult, if I have it correctly. However, I think that the next step is to attach this thrower to a data-node, and that’s where I seem to be stuck: The data-node requires an input device, and while it’s easy enough to get one for input devices other than keyboard and mouse, I don’t see a way to get one for the mouse/keyboard-and-mouse.
For reference, this is what I’m trying to do right now, roughly speaking:
thrower = ButtonThrower("mew")
thrower.setButtonUpEvent("keyInterception")
dataNP = base.dataRoot.attachNewNode(InputDeviceNode(device, device.name))
dataNP.node().addChild(thrower)
eventObject.accept("keyInterception", callbackReference)
The problem there being the “device” variable. :/
Does anyone know how to get an InputDevice for the mouse/keyboard-and-mouse? Or have suggestions for alternate implementations of what I’m trying to do?
[edit]
I’ve found “base.win.getInputDevice(0)” as a potential source for that “device” parameter. Alas, however, substituting it in (along with “base.win.getInputDevice(0).name” for the second parameter) doesn’t seem to be working: my callback isn’t called. Hum…
[edit 2]
Ah, I’d forgotten that one can only have a single InputDeviceNode per device–but one can have multiple ButtonThrowers per InputDeviceNode.
Oddly, however, when I change my code to more or less the following:
testThrower = ButtonThrower("mew")
testThrower.setButtonUpEvent("keyInterception")
dataNP = base.dataRoot.getChild(0)
dataNP.node().addChild(testThrower)
navigationEventObject.accept("keyInterception", callbackReference)
I get my callback as expected–but while the keyboard continues to work as expected, mouse-events seem to only go to this new callback! Pre-existing mouse-events seem to no longer work! :/
[edit 3]
In fact, it seems that it’s messing with extant keyboard events, too–it’s just that the exact symptoms are slightly different. :/
[edit 4]
All right, two alternative questions, towards alternative means of implementing what I want:
-
Is there a way to get a mouse-wheel event from a ButtonThrower via something other than the “button-up” event? (Even something like a “raw button-up” event.)
-
Is there a way to specify that events from a given DirectObject aren’t affected by DirectGUI?