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

This class monitors the state of a number of individual buttons and tracks whether each button is known to be down or up. More...

Public Member Functions

 __init__ ()
 
 __init__ (const ModifierButtons copy)
 
bool addButton (ButtonHandle button)
 Adds the indicated button to the set of buttons that will be monitored for upness and downness. More...
 
 allButtonsUp ()
 Marks all monitored buttons as being in the "up" state. More...
 
bool buttonDown (ButtonHandle button)
 Records that a particular button has been pressed. More...
 
bool buttonUp (ButtonHandle button)
 Records that a particular button has been released. More...
 
ButtonHandle getButton (int index)
 Returns the nth button that the ModifierButtons object is monitoring (the nth button passed to add_button()). More...
 
list getButtons ()
 
int getNumButtons ()
 Returns the number of buttons that the ModifierButtons object is monitoring (e.g. More...
 
str getPrefix ()
 Returns a string which can be used to prefix any button name or event name with the unique set of modifier buttons currently being held. More...
 
bool hasButton (ButtonHandle button)
 Returns true if the indicated button is in the set of buttons being monitored, false otherwise. More...
 
bool isAnyDown ()
 Returns true if any of the tracked button are known to be down, or false if all of them are up. More...
 
bool isDown (ButtonHandle button)
 Returns true if the indicated button is known to be down, or false if it is known to be up or if it is not in the set of buttons being tracked. More...
 
bool isDown (int index)
 Returns true if the indicated button is known to be down, or false if it is known to be up. More...
 
bool matches (const ModifierButtons other)
 Returns true if the set of buttons indicated as down by this ModifierButtons object is the same set of buttons indicated as down by the other ModifierButtons object. More...
 
bool operator != (const ModifierButtons other)
 
ModifierButtons operator & (const ModifierButtons other)
 
ModifierButtons operator &= (const ModifierButtons other)
 
bool operator< (const ModifierButtons other)
 
ModifierButtons operator= (const ModifierButtons copy)
 
bool operator== (const ModifierButtons other)
 
ModifierButtons operator| (const ModifierButtons other)
 
ModifierButtons operator|= (const ModifierButtons other)
 
 output (Ostream out)
 Writes a one-line summary of the buttons known to be down. More...
 
bool removeButton (ButtonHandle button)
 Removes the indicated button from the set of buttons being monitored. More...
 
 setButtonList (const ModifierButtons other)
 Sets the list of buttons to watch to be the same as that of the other ModifierButtons object. More...
 
 write (Ostream out)
 Writes a multi-line summary including all of the buttons being monitored and which ones are known to be down. More...
 

Public Attributes

ButtonHandle buttons []
 

Detailed Description

This class monitors the state of a number of individual buttons and tracks whether each button is known to be down or up.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

◆ __init__() [2/2]

__init__ ( const ModifierButtons  copy)

◆ addButton()

bool addButton ( ButtonHandle  button)

Adds the indicated button to the set of buttons that will be monitored for upness and downness.

Returns true if the button was added, false if it was already being monitored or if too many buttons are currently being monitored.

◆ allButtonsUp()

allButtonsUp ( )

Marks all monitored buttons as being in the "up" state.

◆ buttonDown()

bool buttonDown ( ButtonHandle  button)

Records that a particular button has been pressed.

If the given button is one of the buttons that is currently being monitored, this will update the internal state appropriately; otherwise, it will do nothing. Returns true if the button is one that was monitored, or false otherwise.

◆ buttonUp()

bool buttonUp ( ButtonHandle  button)

Records that a particular button has been released.

If the given button is one of the buttons that is currently being monitored, this will update the internal state appropriately; otherwise, it will do nothing. Returns true if the button is one that was monitored, or false otherwise.

◆ getButton()

ButtonHandle getButton ( int  index)

Returns the nth button that the ModifierButtons object is monitoring (the nth button passed to add_button()).

This must be in the range 0 <= index < get_num_buttons().

◆ getButtons()

list getButtons ( )

◆ getNumButtons()

int getNumButtons ( )

Returns the number of buttons that the ModifierButtons object is monitoring (e.g.

the number of buttons passed to add_button()).

◆ getPrefix()

str getPrefix ( )

Returns a string which can be used to prefix any button name or event name with the unique set of modifier buttons currently being held.

◆ hasButton()

bool hasButton ( ButtonHandle  button)

Returns true if the indicated button is in the set of buttons being monitored, false otherwise.

◆ isAnyDown()

bool isAnyDown ( )

Returns true if any of the tracked button are known to be down, or false if all of them are up.

◆ isDown() [1/2]

bool isDown ( ButtonHandle  button)

Returns true if the indicated button is known to be down, or false if it is known to be up or if it is not in the set of buttons being tracked.

◆ isDown() [2/2]

bool isDown ( int  index)

Returns true if the indicated button is known to be down, or false if it is known to be up.

◆ matches()

bool matches ( const ModifierButtons  other)

Returns true if the set of buttons indicated as down by this ModifierButtons object is the same set of buttons indicated as down by the other ModifierButtons object.

The buttons indicated as up are not relevant.

◆ operator !=()

bool operator != ( const ModifierButtons  other)

◆ operator &()

ModifierButtons operator & ( const ModifierButtons  other)

◆ operator &=()

ModifierButtons operator &= ( const ModifierButtons  other)

◆ operator<()

bool operator< ( const ModifierButtons  other)

◆ operator=()

ModifierButtons operator= ( const ModifierButtons  copy)

◆ operator==()

bool operator== ( const ModifierButtons  other)

◆ operator|()

ModifierButtons operator| ( const ModifierButtons  other)

◆ operator|=()

ModifierButtons operator|= ( const ModifierButtons  other)

◆ output()

output ( Ostream  out)

Writes a one-line summary of the buttons known to be down.

◆ removeButton()

bool removeButton ( ButtonHandle  button)

Removes the indicated button from the set of buttons being monitored.

Returns true if the button was removed, false if it was not being monitored in the first place.

Unlike the other methods, you cannot remove a button by removing its alias; you have to remove exactly the button itself.

◆ setButtonList()

setButtonList ( const ModifierButtons  other)

Sets the list of buttons to watch to be the same as that of the other ModifierButtons object.

This makes the lists pointer equivalent (until one or the other is later modified).

This will preserve the state of any button that was on the original list and is also on the new lists. Any other buttons will get reset to the default state of "up".

◆ write()

write ( Ostream  out)

Writes a multi-line summary including all of the buttons being monitored and which ones are known to be down.

Member Data Documentation

◆ buttons

ButtonHandle buttons[]