panda3d.core.ButtonHandle

from panda3d.core import ButtonHandle
class ButtonHandle

A ButtonHandle represents a single button from any device, including keyboard buttons and mouse buttons (but see KeyboardButton and MouseButton).

Inheritance diagram

Inheritance diagram of ButtonHandle

__init__() → None

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!

__init__(param0: ButtonHandle) → None
__init__(index: int) → None

Constructs a ButtonHandle with the corresponding index number, which may have been returned by an earlier call to ButtonHandle.getIndex().

__init__(name: str) → None

Constructs a ButtonHandle with the corresponding name, which is looked up in the ButtonRegistry. This exists for the purpose of being able to automatically coerce a string into a ButtonHandle; for most purposes, you should use either the static KeyboardButton/MouseButton getters or ButtonRegistry::register_button().

property alias

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.

Return type

ButtonHandle

property ascii_equivalent

Returns the character code associated with the button, or ‘0’ if no ASCII code was associated.

Return type

char

compareTo(other: ButtonHandle) → int

Sorts ButtonHandles arbitrarily (according to <, >, etc.). Returns a number less than 0 if this type sorts before the other one, greater than zero if it sorts after, 0 if they are equivalent.

getAlias() → ButtonHandle

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.

Return type

ButtonHandle

getAsciiEquivalent() → char

Returns the character code associated with the button, or ‘0’ if no ASCII code was associated.

Return type

char

static getClassType() → TypeHandle
Return type

TypeHandle

getHash() → size_t

Returns a hash code suitable for phash_map.

Return type

size_t

getIndex() → int

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.

getName() → str

Returns the name of the button.

hasAsciiEquivalent() → bool

Returns true if the button was created with an ASCII equivalent code (e.g. for a standard keyboard button).

property index

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.

Return type

int

matches(other: ButtonHandle) → bool

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 ==.

property name

Returns the name of the button.

Return type

string

static none() → ButtonHandle
Return type

ButtonHandle

output(out: ostream) → None