I was looking for a way to detect any and all keyboard keys easily, for setting up a keybinding menu in my game, and I came across this old thread:
[url]Detecting any keypress ]
Which says to use
base.buttonThrowers[0].node().setButtonDownEvent("button")
I’m curious what the proper way to clear the ButtonDownEvent when I no longer need it would be. Do I feed it an empty string, or a None-type object? I ask because I couldn’t find a method for clearing it in the API.
drwr
October 7, 2011, 8:50pm
2
From the API reference:
setButtonDownEvent ( string button_down_event )
Specifies the generic event that is generated (if any) each time a key or button is depressed.
Unlike the specific events that are unique to each key, this same event name is used for all button events, and the name of the button pressed (possibly with modifier prefixes) will be sent as a parameter.
If this string is empty, no event is generated. It is possible to generate both generic events and specific events for the same button.
See also set_keystroke_event().
So, just set it to the empty string to turn it off.
David
Tch, I should have read that. I’ve been away from the API for too long.
Sorry for the waste of time question, thanks for the answer.
drwr
October 7, 2011, 9:23pm
4
No worries. I’ll be the first to admit that finding the answer to a particular question isn’t always the easiest to do in the API reference.
David
rdb
October 8, 2011, 8:28am
5
Hm, should I revert to the old API reference then?
I don’t believe I’m well versed enough on the differences between the two systems to give a qualified opinion.
drwr
October 8, 2011, 1:50pm
7
I don’t think there was a problem in the API reference itself, in this case; it’s just that the needed text wasn’t necessarily easy to find, because it’s a reference and not a tutorial or manual.
David