Panda3D
Classes | Public Member Functions | Static Public Member Functions

ButtonRegistry Class Reference

The ButtonRegistry class maintains all the assigned ButtonHandles in a given system. More...

#include "buttonRegistry.h"

List of all members.

Classes

class  RegistryNode

Public Member Functions

ButtonHandle find_ascii_button (char ascii_equivalent) const
 Finds a ButtonHandle in the registry matching the indicated ASCII equivalent character.
ButtonHandle get_alias (ButtonHandle button) const
 Returns the alias for the indicated button, or ButtonHandle::none() if the button has no specified alias.
ButtonHandle get_button (const string &name)
 Finds a ButtonHandle in the registry matching the indicated name.
string get_name (ButtonHandle button) const
 Returns the name of the indicated button.
bool register_button (ButtonHandle &button_handle, const string &name, ButtonHandle alias=ButtonHandle::none(), char ascii_equivalent= '\0')
 Registers a new ButtonHandle with the indicated name, and if specified, the indicated ASCII equivalent.
void write (ostream &out) const

Static Public Member Functions

static ButtonRegistryptr ()
 Returns the pointer to the global ButtonRegistry object.

Detailed Description

The ButtonRegistry class maintains all the assigned ButtonHandles in a given system.

There should be only one ButtonRegistry class during the lifetime of the application.

Definition at line 32 of file buttonRegistry.h.


Member Function Documentation

ButtonHandle ButtonRegistry::find_ascii_button ( char  ascii_equivalent) const

Finds a ButtonHandle in the registry matching the indicated ASCII equivalent character.

If there is no such ButtonHandle, returns ButtonHandle::none().

Definition at line 142 of file buttonRegistry.cxx.

References ButtonHandle::none().

Referenced by KeyboardButton::ascii_key().

ButtonHandle ButtonRegistry::get_alias ( ButtonHandle  button) const [inline]

Returns the alias for the indicated button, or ButtonHandle::none() if the button has no specified alias.

Definition at line 62 of file buttonRegistry.I.

References ButtonHandle::none().

Referenced by ButtonHandle::get_alias().

ButtonHandle ButtonRegistry::get_button ( const string &  name)

Finds a ButtonHandle in the registry matching the indicated name.

If there is no such ButtonHandle, registers a new one and returns it.

Definition at line 121 of file buttonRegistry.cxx.

References register_button().

Referenced by ButtonEvent::read_datagram().

string ButtonRegistry::get_name ( ButtonHandle  button) const [inline]

Returns the name of the indicated button.

Definition at line 48 of file buttonRegistry.I.

Referenced by ButtonHandle::get_name().

ButtonRegistry * ButtonRegistry::ptr ( ) [inline, static]
bool ButtonRegistry::register_button ( ButtonHandle button_handle,
const string &  name,
ButtonHandle  alias = ButtonHandle::none(),
char  ascii_equivalent = '\0' 
)

Registers a new ButtonHandle with the indicated name, and if specified, the indicated ASCII equivalent.

Returns true if the button was registered, or false it was already registered; in either case, the new ButtonHandle is loaded into the first parameter.

If the alias is not ButtonHandle::none(), it indicates an alias (alternate name) for the same button. 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.

This defines a new kind of button matching the indicated name. The ButtonHandle can then be passed around to devices as a button in its own right.

Definition at line 50 of file buttonRegistry.cxx.

Referenced by get_button(), KeyboardButton::init_keyboard_buttons(), and MouseButton::init_mouse_buttons().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations