mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
extend ascii_key to accept a string as well as a character
This commit is contained in:
parent
d31a882b09
commit
2b080112c3
@ -33,6 +33,23 @@ ascii_key(char ascii_equivalent) {
|
||||
return ButtonRegistry::ptr()->find_ascii_button(ascii_equivalent);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: KeyboardButton::ascii_key
|
||||
// Access: Public, Static
|
||||
// Description: Returns the ButtonHandle associated with the
|
||||
// particular ASCII character (taken from the first
|
||||
// character of the indicated string), if there is one,
|
||||
// or ButtonHandle::none() if there is not.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
ButtonHandle KeyboardButton::
|
||||
ascii_key(const string &ascii_equivalent) {
|
||||
if (ascii_equivalent.empty()) {
|
||||
return ButtonHandle::none();
|
||||
} else {
|
||||
return ButtonRegistry::ptr()->find_ascii_button(ascii_equivalent[0]);
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFINE_KEYBD_BUTTON_HANDLE(KeyName) \
|
||||
static ButtonHandle _##KeyName; \
|
||||
ButtonHandle KeyboardButton::KeyName() { return _##KeyName; }
|
||||
|
@ -32,6 +32,7 @@
|
||||
class EXPCL_PANDA KeyboardButton {
|
||||
PUBLISHED:
|
||||
static ButtonHandle ascii_key(char ascii_equivalent);
|
||||
static ButtonHandle ascii_key(const string &ascii_equivalent);
|
||||
|
||||
static ButtonHandle space();
|
||||
static ButtonHandle backspace();
|
||||
|
Loading…
x
Reference in New Issue
Block a user