Panda3D
|
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse buttons (but see KeyboardButton and MouseButton). More...
#include "buttonHandle.h"
Public Member Functions | |
ButtonHandle () | |
The default constructor must do nothing, because we can't guarantee ordering of static initializers. | |
ButtonHandle (int index) | |
Constructs a ButtonHandle with the corresponding index number, which may have been returned by an earlier call to ButtonHandle::get_index(). | |
ButtonHandle (const ButtonHandle ©) | |
ButtonHandle | get_alias () const |
Returns the alias (alternate name) associated with the button, if any, or ButtonHandle::none() if the button has no alias. | |
char | get_ascii_equivalent () const |
Returns the character code associated with the button, or '\0' if no ASCII code was associated. | |
int | get_index () const |
Returns the integer index associated with this ButtonHandle. | |
string | get_name () const |
Returns the name of the button. | |
bool | has_ascii_equivalent () const |
Returns true if the button was created with an ASCII equivalent code (e.g. | |
bool | matches (const ButtonHandle &other) const |
Returns true if this ButtonHandle is the same as the other one, or if the other one is an alias for this one. | |
bool | operator!= (const ButtonHandle &other) const |
bool | operator< (const ButtonHandle &other) const |
bool | operator== (const ButtonHandle &other) const |
void | output (ostream &out) const |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static ButtonHandle | none () |
Returns a special zero-valued ButtonHandle that is used to indicate no button. | |
Friends | |
class | ButtonRegistry |
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse buttons (but see KeyboardButton and MouseButton).
Definition at line 28 of file buttonHandle.h.
ButtonHandle::ButtonHandle | ( | ) | [inline] |
The default constructor must do nothing, because we can't guarantee ordering of static initializers.
If the constructor tried to initialize its value, it might happen after the value had already been set previously by another static initializer!
Definition at line 26 of file buttonHandle.I.
ButtonHandle::ButtonHandle | ( | int | index | ) | [inline] |
Constructs a ButtonHandle with the corresponding index number, which may have been returned by an earlier call to ButtonHandle::get_index().
Definition at line 37 of file buttonHandle.I.
ButtonHandle ButtonHandle::get_alias | ( | ) | const |
Returns the alias (alternate name) associated with the button, if any, or ButtonHandle::none() if the button has no alias.
Each button is allowed to have one alias, and multiple different buttons can refer to the same alias. The alias should be the more general name for the button, for instance, shift is an alias for lshift, but not vice-versa.
Definition at line 51 of file buttonHandle.cxx.
References ButtonRegistry::get_alias(), none(), and ButtonRegistry::ptr().
Referenced by matches().
char ButtonHandle::get_ascii_equivalent | ( | ) | const [inline] |
Returns the character code associated with the button, or '\0' if no ASCII code was associated.
Definition at line 98 of file buttonHandle.I.
References has_ascii_equivalent().
Referenced by x11GraphicsWindow::handle_keystroke().
int ButtonHandle::get_index | ( | ) | const [inline] |
Returns the integer index associated with this ButtonHandle.
Each different ButtonHandle will have a different index. However, you probably shouldn't be using this method; you should just treat the ButtonHandles as opaque classes. This is provided for the convenience of non-C++ scripting languages to build a hashtable of ButtonHandles.
Definition at line 131 of file buttonHandle.I.
Referenced by MouseWatcher::do_transmit_data(), AwMouseAndKeyboard::do_transmit_data(), RocketInputHandler::get_rocket_key(), and MouseWatcher::is_button_down().
string ButtonHandle::get_name | ( | ) | const |
Returns the name of the button.
Definition at line 29 of file buttonHandle.cxx.
References ButtonRegistry::get_name(), none(), and ButtonRegistry::ptr().
Referenced by ButtonThrower::do_transmit_data(), AwMouseAndKeyboard::do_transmit_data(), PGEntry::get_accept_event(), PGEntry::get_accept_failed_event(), PGButton::get_click_event(), PGItem::get_press_event(), PGItem::get_release_event(), PGItem::get_repeat_event(), MouseWatcher::throw_event_pattern(), ButtonThrower::write(), and ButtonEvent::write_datagram().
bool ButtonHandle::has_ascii_equivalent | ( | ) | const [inline] |
Returns true if the button was created with an ASCII equivalent code (e.g.
for a standard keyboard button).
Definition at line 87 of file buttonHandle.I.
Referenced by get_ascii_equivalent(), and x11GraphicsWindow::handle_keystroke().
bool ButtonHandle::matches | ( | const ButtonHandle & | other | ) | const [inline] |
Returns true if this ButtonHandle is the same as the other one, or if the other one is an alias for this one.
(Does not return true if this button is an alias for the other one, however.)
This is a more general comparison than operator ==.
Definition at line 113 of file buttonHandle.I.
References get_alias(), and none().
Referenced by ModifierButtons::button_down(), ModifierButtons::button_up(), ModifierButtons::has_button(), and ModifierButtons::is_down().
ButtonHandle ButtonHandle::none | ( | ) | [inline, static] |
Returns a special zero-valued ButtonHandle that is used to indicate no button.
Definition at line 152 of file buttonHandle.I.
Referenced by ModifierButtons::add_button(), KeyboardButton::ascii_key(), MouseButton::button(), MouseWatcher::clear_current_regions(), MouseWatcher::enter_region(), MouseWatcher::exit_region(), ButtonRegistry::find_ascii_button(), ButtonRegistry::get_alias(), get_alias(), x11GraphicsWindow::get_button(), ModifierButtons::get_button(), ClientButtonDevice::get_button_map(), get_name(), x11GraphicsWindow::handle_keypress(), x11GraphicsWindow::handle_keyrelease(), KeyboardButton::init_keyboard_buttons(), x11GraphicsWindow::map_button(), matches(), ClientButtonDevice::set_button_state(), MouseWatcher::throw_event_pattern(), MouseWatcher::within_region(), MouseWatcher::without_region(), and ClientButtonDevice::write_buttons().