Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ButtonHandle Class Reference

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

Public Member Functions

 __init__ ()
 
 __init__ (const ButtonHandle)
 
 __init__ (int index)
 Constructs a ButtonHandle with the corresponding index number, which may have been returned by an earlier call to ButtonHandle::get_index(). More...
 
 __init__ (str name)
 Constructs a ButtonHandle with the corresponding name, which is looked up in the ButtonRegistry. More...
 
int compareTo (const ButtonHandle other)
 Sorts ButtonHandles arbitrarily (according to <, >, etc.). More...
 
ButtonHandle getAlias ()
 Returns the alias (alternate name) associated with the button, if any, or ButtonHandle::none() if the button has no alias. More...
 
char getAsciiEquivalent ()
 Returns the character code associated with the button, or '\0' if no ASCII code was associated. More...
 
int getHash ()
 Returns a hash code suitable for phash_map. More...
 
int getIndex ()
 Returns the integer index associated with this ButtonHandle. More...
 
str getName ()
 Returns the name of the button. More...
 
bool hasAsciiEquivalent ()
 Returns true if the button was created with an ASCII equivalent code (e.g. More...
 
bool matches (const ButtonHandle other)
 Returns true if this ButtonHandle is the same as the other one, or if the other one is an alias for this one. More...
 
bool operator != (const ButtonHandle other)
 
bool operator > (const ButtonHandle other)
 
bool operator >= (const ButtonHandle other)
 
bool operator< (const ButtonHandle other)
 
bool operator<= (const ButtonHandle other)
 
bool operator== (const ButtonHandle other)
 
 output (Ostream out)
 

Static Public Member Functions

static TypeHandle getClassType ()
 
static ButtonHandle none ()
 

Public Attributes

ButtonHandle alias
 Returns the alias (alternate name) associated with the button, if any, or ButtonHandle::none() if the button has no alias. More...
 
char ascii_equivalent
 Returns the character code associated with the button, or '\0' if no ASCII code was associated. More...
 
int index
 Returns the integer index associated with this ButtonHandle. More...
 
String name
 Returns the name of the button. More...
 

Detailed Description

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

Member Function Documentation

◆ __init__() [1/4]

__init__ ( )

◆ __init__() [2/4]

__init__ ( const  ButtonHandle)

◆ __init__() [3/4]

__init__ ( int  index)

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

◆ __init__() [4/4]

__init__ ( str  name)

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().

◆ compareTo()

int compareTo ( const ButtonHandle  other)

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 getAlias ( )

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.

◆ getAsciiEquivalent()

char getAsciiEquivalent ( )

Returns the character code associated with the button, or '\0' if no ASCII code was associated.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getHash()

int getHash ( )

Returns a hash code suitable for phash_map.

◆ getIndex()

int getIndex ( )

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 getName ( )

Returns the name of the button.

◆ hasAsciiEquivalent()

bool hasAsciiEquivalent ( )

Returns true if the button was created with an ASCII equivalent code (e.g.

for a standard keyboard button).

◆ matches()

bool matches ( const ButtonHandle  other)

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

◆ none()

static ButtonHandle none ( )
static

◆ operator !=()

bool operator != ( const ButtonHandle  other)

◆ operator >()

bool operator > ( const ButtonHandle  other)

◆ operator >=()

bool operator >= ( const ButtonHandle  other)

◆ operator<()

bool operator< ( const ButtonHandle  other)

◆ operator<=()

bool operator<= ( const ButtonHandle  other)

◆ operator==()

bool operator== ( const ButtonHandle  other)

◆ output()

output ( Ostream  out)

Member Data Documentation

◆ alias

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

◆ ascii_equivalent

char ascii_equivalent

Returns the character code associated with the button, or '\0' if no ASCII code was associated.

◆ index

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

◆ name

String name

Returns the name of the button.