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

Records a button event of some kind. More...

#include "buttonEvent.h"

Public Types

enum  Type {
  T_down, T_resume_down, T_up, T_repeat,
  T_keystroke, T_candidate, T_move, T_raw_down,
  T_raw_up
}
 

Public Member Functions

 ButtonEvent (ButtonHandle button, Type type, double time=ClockObject::get_global_clock() ->get_frame_time())
 
 ButtonEvent (int keycode, double time=ClockObject::get_global_clock() ->get_frame_time())
 
 ButtonEvent (const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos)
 
 ButtonEvent (const ButtonEvent &copy)
 
bool operator != (const ButtonEvent &other) const
 
bool operator< (const ButtonEvent &other) const
 
void operator= (const ButtonEvent &copy)
 
bool operator== (const ButtonEvent &other) const
 The equality operator does not consider time significant. More...
 
void output (std::ostream &out) const
 
void read_datagram (DatagramIterator &scan)
 Restores the event from the datagram. More...
 
bool update_mods (ModifierButtons &mods) const
 Calls button_down() or button_up(), as appropriate, according to the ButtonEvent. More...
 
void write_datagram (Datagram &dg) const
 Writes the event into a datagram. More...
 

Public Attributes

ButtonHandle _button
 
std::wstring _candidate_string
 
size_t _cursor_pos
 
size_t _highlight_end
 
size_t _highlight_start
 
int _keycode
 
double _time
 
Type _type
 

Detailed Description

Records a button event of some kind.

This is either a keyboard or mouse button (or some other kind of button) changing state from up to down, or vice-versa, or it is a single "keystroke".

A keystroke is different than a button event in that (a) it does not necessarily correspond to a physical button on a keyboard, but might be the result of a combination of buttons (e.g. "A" is the result of shift + "a"); and (b) it does not manage separate "up" and "down" events, but is itself an instantaneous event.

Normal up/down button events can be used to track the state of a particular button on the keyboard, while keystroke events are best used to monitor what a user is attempting to type.

Button up/down events are defined across all the physical keys on the keyboard (and other buttons for which there is a corresponding ButtonHandle object), while keystroke events are defined across the entire Unicode character set.

Definition at line 46 of file buttonEvent.h.

Member Function Documentation

◆ operator==()

bool ButtonEvent::operator== ( const ButtonEvent other) const
inline

The equality operator does not consider time significant.

Definition at line 106 of file buttonEvent.I.

◆ read_datagram()

void ButtonEvent::read_datagram ( DatagramIterator scan)

◆ update_mods()

bool ButtonEvent::update_mods ( ModifierButtons mods) const
inline

Calls button_down() or button_up(), as appropriate, according to the ButtonEvent.

Definition at line 140 of file buttonEvent.I.

References ModifierButtons::button_down(), and ModifierButtons::button_up().

◆ write_datagram()

void ButtonEvent::write_datagram ( Datagram dg) const

Writes the event into a datagram.

Definition at line 70 of file buttonEvent.cxx.

References Datagram::add_string(), Datagram::add_uint16(), Datagram::add_uint8(), TextEncoder::encode_wtext(), and ButtonHandle::get_name.


The documentation for this class was generated from the following files: