Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions

ButtonThrower Class Reference

Throws Panda Events for button down/up events generated within the data graph. More...

#include "buttonThrower.h"

Inheritance diagram for ButtonThrower:
DataNode PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase

List of all members.

Public Member Functions

 ButtonThrower (const string &name)
void add_parameter (const EventParameter &obj)
 Adds the indicated parameter to the list of parameters that will be passed with each event generated by this ButtonThrower.
bool add_throw_button (const ModifierButtons &mods, const ButtonHandle &button)
 Adds a new button to the set of buttons that the ButtonThrower explicitly processes.
void clear_throw_buttons ()
 Empties the set of buttons that were added via add_throw_button().
virtual TypeHandle force_init_type ()
const string & get_button_down_event () const
 Returns the button_down_event that has been set on this ButtonThrower.
const string & get_button_repeat_event () const
 Returns the button_repeat_event that has been set on this ButtonThrower.
const string & get_button_up_event () const
 Returns the button_up_event that has been set on this ButtonThrower.
const string & get_candidate_event () const
 Returns the candidate_event that has been set on this ButtonThrower.
const string & get_keystroke_event () const
 Returns the keystroke_event that has been set on this ButtonThrower.
const ModifierButtonsget_modifier_buttons () const
 Returns the set of ModifierButtons that the ButtonThrower will consider important enough to prepend the event name with.
const string & get_move_event () const
 Returns the move_event that has been set on this ButtonThrower.
int get_num_parameters () const
 Returns the number of parameters that have been added to the list of parameters to be passed with each event generated by this ButtonThrower.
EventParameter get_parameter (int n) const
 Returns the nth parameter that has been added to the list of parameters passed with each event generated by this ButtonThrower.
const string & get_prefix () const
 Returns the prefix that has been set on this ButtonThrower.
bool get_specific_flag () const
 Returns the flag that indicates whether specific events should be generated.
bool get_throw_buttons_active () const
 Returns the flag that indicates whether the ButtonThrower will only process events for the explicitly named buttons or not.
bool get_time_flag () const
 Returns the flag that indicates whether the time of the button event should be passed as a parameter.
virtual TypeHandle get_type () const
bool has_throw_button (const ButtonHandle &button) const
 Returns true if the indicated button, in conjunction with any nonspecified modifier buttons, is on the set of buttons that will be processed by the ButtonThrower.
bool has_throw_button (const ModifierButtons &mods, const ButtonHandle &button) const
 Returns true if the indicated button is on the set of buttons that will be processed by the ButtonThrower, false otherwise.
 MAKE_SEQ (get_parameters, get_num_parameters, get_parameter)
bool remove_throw_button (const ModifierButtons &mods, const ButtonHandle &button)
 Removes the indicated button from the set of buttons that the ButtonThrower explicitly processes.
void set_button_down_event (const string &button_down_event)
 Specifies the generic event that is generated (if any) each time a key or button is depressed.
void set_button_repeat_event (const string &button_repeat_event)
 Specifies the generic event that is generated (if any) repeatedly while a key or button is held down.
void set_button_up_event (const string &button_up_event)
 Specifies the generic event that is generated (if any) each time a key or button is released.
void set_candidate_event (const string &candidate_event)
 Specifies the event that is generated (if any) for each IME candidate string event received.
void set_keystroke_event (const string &keystroke_event)
 Specifies the event that is generated (if any) for each keystroke that is received.
void set_modifier_buttons (const ModifierButtons &mods)
 Changes the set of ModifierButtons that the ButtonThrower will consider important enough to prepend the event name with.
void set_move_event (const string &move_event)
 Specifies the event that is generated (if any) each time the mouse is moved within the window.
void set_prefix (const string &prefix)
 Sets the prefix which is prepended to all specific event names (that is, event names generated from the button name itself, as opposed to the generic event names like set_button_down_event) thrown by this object.
void set_specific_flag (bool specific_flag)
 Sets the flag that indicates whether specific events (events prefixed by set_prefix, and based on the event name) should be generated at all.
void set_throw_buttons_active (bool flag)
 Sets the flag that indicates whether the ButtonThrower will only process events for the explicitly named buttons or not.
void set_time_flag (bool time_flag)
 Sets the flag that indicates whether the time of the button event should be passed as a parameter or not.
virtual void write (ostream &out, int indent_level=0) const
 Throw all events for button events found in the data element.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Protected Member Functions

virtual void do_transmit_data (DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &output)
 The virtual implementation of transmit_data().

Detailed Description

Throws Panda Events for button down/up events generated within the data graph.

This is a DataNode which is intended to be parented to the data graph below a device which is generating a sequence of button events, like a MouseAndKeyboard device. It simply takes each button it finds and throws a corresponding event based on the button name via the throw_event() call.

Definition at line 39 of file buttonThrower.h.


Member Function Documentation

void ButtonThrower::add_parameter ( const EventParameter obj)

Adds the indicated parameter to the list of parameters that will be passed with each event generated by this ButtonThrower.

Definition at line 65 of file buttonThrower.cxx.

bool ButtonThrower::add_throw_button ( const ModifierButtons mods,
const ButtonHandle button 
)

Adds a new button to the set of buttons that the ButtonThrower explicitly processes.

If set_throw_buttons_active is false (which is the default), the ButtonThrower will process all buttons. Otherwise, the ButtonThrower will only process events for the button(s) explicitly named by this function; buttons not on the list will be ignored by this object and passed on downstream to the child node(s) in the data graph. A button that *is* on the list will be processed by the ButtonThrower and not passed on to the child node(s).

The return value is true if the button is added, or false if it was already in the set.

Definition at line 115 of file buttonThrower.cxx.

References ModifierButtons::matches().

void ButtonThrower::clear_throw_buttons ( )

Empties the set of buttons that were added via add_throw_button().

See add_throw_button().

Definition at line 231 of file buttonThrower.cxx.

void ButtonThrower::do_transmit_data ( DataGraphTraverser trav,
const DataNodeTransmit input,
DataNodeTransmit output 
) [protected, virtual]

The virtual implementation of transmit_data().

This function receives an array of input parameters and should generate an array of output parameters. The input parameters may be accessed with the index numbers returned by the define_input() calls that were made earlier (presumably in the constructor); likewise, the output parameters should be set with the index numbers returned by the define_output() calls.

Reimplemented from DataNode.

Definition at line 377 of file buttonThrower.cxx.

References ModifierButtons::button_down(), ModifierButtons::button_up(), DataNodeTransmit::get_data(), ButtonEventList::get_event(), ButtonHandle::get_name(), ButtonEventList::get_num_events(), ModifierButtons::get_prefix(), EventParameter::get_ptr(), DataNodeTransmit::has_data(), has_throw_button(), and DataNodeTransmit::set_data().

const string & ButtonThrower::get_button_down_event ( ) const [inline]

Returns the button_down_event that has been set on this ButtonThrower.

See set_button_down_event().

Definition at line 44 of file buttonThrower.I.

const string & ButtonThrower::get_button_repeat_event ( ) const [inline]

Returns the button_repeat_event that has been set on this ButtonThrower.

See set_button_repeat_event().

Definition at line 99 of file buttonThrower.I.

const string & ButtonThrower::get_button_up_event ( ) const [inline]

Returns the button_up_event that has been set on this ButtonThrower.

See set_button_up_event().

Definition at line 67 of file buttonThrower.I.

const string & ButtonThrower::get_candidate_event ( ) const [inline]

Returns the candidate_event that has been set on this ButtonThrower.

See set_candidate_event().

Definition at line 177 of file buttonThrower.I.

const string & ButtonThrower::get_keystroke_event ( ) const [inline]

Returns the keystroke_event that has been set on this ButtonThrower.

See set_keystroke_event().

Definition at line 139 of file buttonThrower.I.

const ModifierButtons & ButtonThrower::get_modifier_buttons ( ) const [inline]

Returns the set of ModifierButtons that the ButtonThrower will consider important enough to prepend the event name with.

Normally, this set will be empty, and the ButtonThrower will therefore ignore all ModifierButtons attached to the key events, but if one or more buttons have been added to this set, and those modifier buttons are set on the button event, then the event name will be prepended with the names of the modifier buttons.

Definition at line 296 of file buttonThrower.I.

const string & ButtonThrower::get_move_event ( ) const [inline]

Returns the move_event that has been set on this ButtonThrower.

See set_move_event().

Definition at line 199 of file buttonThrower.I.

int ButtonThrower::get_num_parameters ( ) const

Returns the number of parameters that have been added to the list of parameters to be passed with each event generated by this ButtonThrower.

Definition at line 78 of file buttonThrower.cxx.

EventParameter ButtonThrower::get_parameter ( int  n) const

Returns the nth parameter that has been added to the list of parameters passed with each event generated by this ButtonThrower.

Definition at line 90 of file buttonThrower.cxx.

const string & ButtonThrower::get_prefix ( ) const [inline]

Returns the prefix that has been set on this ButtonThrower.

See set_prefix().

Definition at line 224 of file buttonThrower.I.

bool ButtonThrower::get_specific_flag ( ) const [inline]

Returns the flag that indicates whether specific events should be generated.

See set_specific_flag().

Definition at line 250 of file buttonThrower.I.

bool ButtonThrower::get_throw_buttons_active ( ) const [inline]

Returns the flag that indicates whether the ButtonThrower will only process events for the explicitly named buttons or not.

See set_throw_buttons_active().

Definition at line 347 of file buttonThrower.I.

bool ButtonThrower::get_time_flag ( ) const [inline]

Returns the flag that indicates whether the time of the button event should be passed as a parameter.

Definition at line 278 of file buttonThrower.I.

bool ButtonThrower::has_throw_button ( const ButtonHandle button) const

Returns true if the indicated button, in conjunction with any nonspecified modifier buttons, is on the set of buttons that will be processed by the ButtonThrower.

That is to say, returns true if this button was ever passed as the second parameter add_throw_button(), regardless of what the first parameter was.

Definition at line 213 of file buttonThrower.cxx.

bool ButtonThrower::has_throw_button ( const ModifierButtons mods,
const ButtonHandle button 
) const

Returns true if the indicated button is on the set of buttons that will be processed by the ButtonThrower, false otherwise.

See add_throw_button().

Definition at line 178 of file buttonThrower.cxx.

References ModifierButtons::matches().

Referenced by do_transmit_data().

bool ButtonThrower::remove_throw_button ( const ModifierButtons mods,
const ButtonHandle button 
)

Removes the indicated button from the set of buttons that the ButtonThrower explicitly processes.

See add_throw_button().

The return value is true if the button is removed, or false if it was not on the set.

Definition at line 143 of file buttonThrower.cxx.

References ModifierButtons::matches().

void ButtonThrower::set_button_down_event ( const string &  button_down_event) [inline]

Specifies the generic event that is generated (if any) each time a key or button is depressed.

Unlike the specific events that are unique to each key, this same event name is used for *all* button events, and the name of the button pressed (possibly with modifier prefixes) will be sent as a parameter.

If this string is empty, no event is generated. It is possible to generate both generic events and specific events for the same button.

See also set_keystroke_event().

Definition at line 33 of file buttonThrower.I.

void ButtonThrower::set_button_repeat_event ( const string &  button_repeat_event) [inline]

Specifies the generic event that is generated (if any) repeatedly while a key or button is held down.

Unlike the specific events that are unique to each key, this same event name is used for *all* button events, and the name of the button pressed (possibly with modifier prefixes) will be sent as a parameter.

If this string is empty, no event is generated. It is possible to generate both generic events and specific events for the same button.

See also set_keystroke_event().

Definition at line 88 of file buttonThrower.I.

void ButtonThrower::set_button_up_event ( const string &  button_up_event) [inline]

Specifies the generic event that is generated (if any) each time a key or button is released.

See set_button_down_event().

Definition at line 56 of file buttonThrower.I.

void ButtonThrower::set_candidate_event ( const string &  candidate_event) [inline]

Specifies the event that is generated (if any) for each IME candidate string event received.

Events of this nature are received only when the user is entering data using a Microsoft Input Method Editor, typically used for Asian languages such as Japanese or Korean.

If you are designing a typing user interface, you should track this event to support the use of the IME. In response to this event, you should display the candidate string in the entry box, with the appropriate sections highlighted, so the user can scroll through the available choices.

This event is generated with four parameters, in order: the candidate string, the character at which to start the highlight, the character at which to end the highlight, and the current cursor position.

Definition at line 166 of file buttonThrower.I.

void ButtonThrower::set_keystroke_event ( const string &  keystroke_event) [inline]

Specifies the event that is generated (if any) for each keystroke that is received.

A keystroke is different than a button event: it represents the semantic meaning of the sequence of keys that have been pressed. For instance, pressing shift and 4 together will generate the button event "shift-4", but it will generate the keystroke "$".

If a key is held down, keyrepeat will cause the same keystroke event to be generated repeatedly. This is different from the corresponding down event, which will only be generated once, followed by a number of button repeat events.

This event is generated with a single wstring parameter, which is a one-character string that contains the keystroke generated. If this event string is empty, no event is generated.

See also set_button_down_event().

Definition at line 128 of file buttonThrower.I.

void ButtonThrower::set_modifier_buttons ( const ModifierButtons mods) [inline]

Changes the set of ModifierButtons that the ButtonThrower will consider important enough to prepend the event name with.

Normally, this set will be empty, and the ButtonThrower will therefore ignore all ModifierButtons attached to the key events, but if one or more buttons have been added to this set, then the event name will be prepended with the names of the modifier buttons.

It is recommended that you change this setting by first calling get_modifier_buttons(), making adjustments, and passing the new value to set_modifier_buttons(). This way the current state of the modifier buttons will not be lost.

Definition at line 319 of file buttonThrower.I.

void ButtonThrower::set_move_event ( const string &  move_event) [inline]

Specifies the event that is generated (if any) each time the mouse is moved within the window.

Definition at line 188 of file buttonThrower.I.

void ButtonThrower::set_prefix ( const string &  prefix) [inline]

Sets the prefix which is prepended to all specific event names (that is, event names generated from the button name itself, as opposed to the generic event names like set_button_down_event) thrown by this object.

Definition at line 213 of file buttonThrower.I.

void ButtonThrower::set_specific_flag ( bool  specific_flag) [inline]

Sets the flag that indicates whether specific events (events prefixed by set_prefix, and based on the event name) should be generated at all.

This is true by default, but may be disabled if you are only interested in the generic events (for instance, events like set_button_down_event).

Definition at line 239 of file buttonThrower.I.

void ButtonThrower::set_throw_buttons_active ( bool  flag) [inline]

Sets the flag that indicates whether the ButtonThrower will only process events for the explicitly named buttons or not.

Normally this is false, meaning all buttons are processed; set it true to indicate that only some buttons should be processed. See add_throw_button().

Definition at line 334 of file buttonThrower.I.

void ButtonThrower::set_time_flag ( bool  time_flag) [inline]

Sets the flag that indicates whether the time of the button event should be passed as a parameter or not.

When this is true, an additional parameter is generated on each event (before all the parameters named by add_parameter) that consists of a single double value, and reflects the time the button was pressed or released, as a value from ClockObject::get_global_clock().

Definition at line 267 of file buttonThrower.I.

void ButtonThrower::write ( ostream &  out,
int  indent_level = 0 
) const [virtual]

Throw all events for button events found in the data element.

Reimplemented from PandaNode.

Definition at line 242 of file buttonThrower.cxx.

References ButtonHandle::get_name().


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