Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::KeyEvent Class Reference

Key press or release event class. More...

#include <KeyEvent.h>

Inheritance diagram for gadget::KeyEvent:

Inheritance graph
[legend]
Collaboration diagram for gadget::KeyEvent:

Collaboration graph
[legend]
List of all members.

Public Methods

 KeyEvent (const gadget::EventType type, const gadget::Keys key, int mask, unsigned long time, char asciiKey=0)
 Initializes data members. More...

 KeyEvent ()
 Default constructor needed in order to use the templated EventFactory without modification. More...

const gadget::KeysgetKey () const
 Get the key that was pressed while generating this event. More...

const int & getModifierMask () const
 Returns the modifier mask for this event. More...

const char & getKeyChar () const
 Returns the ASCII character corresponding to the key that was pressed. More...

virtual vpr::ReturnStatus writeObject (vpr::ObjectWriter *writer)
 Serializes this event using the given ObjectWriter. More...

virtual vpr::ReturnStatus readObject (vpr::ObjectReader *reader)
 De-serializes this event using the given ObjectReader. More...


Protected Attributes

gadget::Keys mKey
 The actual key pressed. More...

int mModifierMask
 The mask of any modifiers in addition to mKey. More...

char mAsciiKey
 ASCCI representation of key pressed. More...


Detailed Description

Key press or release event class.

Definition at line 53 of file KeyEvent.h.


Constructor & Destructor Documentation

gadget::KeyEvent::KeyEvent const gadget::EventType    type,
const gadget::Keys    key,
int    mask,
unsigned long    time,
char    asciiKey = 0
 

Initializes data members.

Parameters:
key  The platform-independent value of the key that was pressed or released.
isKeyPress  Flag indicating whether this is a key press event (true) or a key release event (false).
mask  The mask of modifiers pressed in addition to key. This should be constructed using the bitwise OR of gadget::ModifierMask values.
time  The time at which this event occurred. This should be as accurate as possible, preferabbly acquired from the operating system or windowing system event data structure. The time at which the event was processed is not an acceptable value.
asciiKey  The ASCII value of the key associated with this event. This parameter is optional, and it defaults to 0 if not specified.
See also:
gadget::ModifierMask

Definition at line 43 of file KeyEvent.cpp.

00045    : gadget::Event(type, time)
00046    , mKey(key)
00047    , mModifierMask(mask)
00048    , mAsciiKey(asciiKey)
00049 {
00050 }

gadget::KeyEvent::KeyEvent  
 

Default constructor needed in order to use the templated EventFactory without modification.

The EventFactory was needed to allow the correct subtype of Event, KeyEvent in this case, to be created during de-serialization.

Definition at line 52 of file KeyEvent.cpp.

References gadget::KEY_SPACE, and gadget::NoEvent.

00053    : gadget::Event(NoEvent, 0)
00054    , mKey(gadget::KEY_SPACE)
00055    , mModifierMask(0)
00056    , mAsciiKey(' ')
00057 {
00058 }


Member Function Documentation

const gadget::Keys& gadget::KeyEvent::getKey   const [inline]
 

Get the key that was pressed while generating this event.

Definition at line 91 of file KeyEvent.h.

00092    {
00093       return mKey;
00094    }

const int& gadget::KeyEvent::getModifierMask   const [inline]
 

Returns the modifier mask for this event.

This tells which modifier keys (if any) were pressed at the same time as the key that was pressed or released. The mask is the bitwise OR of values in the enumeration gadget::ModifierMask.

See also:
gadget::ModifierMask

Definition at line 104 of file KeyEvent.h.

00105    {
00106       return mModifierMask;
00107    }

const char& gadget::KeyEvent::getKeyChar   const [inline]
 

Returns the ASCII character corresponding to the key that was pressed.

Definition at line 112 of file KeyEvent.h.

00113    {
00114       return mAsciiKey;
00115    }

vpr::ReturnStatus gadget::KeyEvent::writeObject vpr::ObjectWriter *    writer [virtual]
 

Serializes this event using the given ObjectWriter.

Reimplemented from gadget::Event.

Definition at line 61 of file KeyEvent.cpp.

References mAsciiKey, mKey, mModifierMask, gadget::Event::mTime, and gadget::Event::mType.

00062 {
00063    writer->writeUint16(mType);
00064 
00065    // Serialize all member variables
00066    writer->writeUint32(mKey);
00067    writer->writeUint32(mModifierMask);
00068    writer->writeUint64(mTime);
00069    writer->writeUint8(mAsciiKey);
00070       
00071    return vpr::ReturnStatus::Succeed;
00072 }

vpr::ReturnStatus gadget::KeyEvent::readObject vpr::ObjectReader *    reader [virtual]
 

De-serializes this event using the given ObjectReader.

Reimplemented from gadget::Event.

Definition at line 75 of file KeyEvent.cpp.

References mAsciiKey, mKey, mModifierMask, and gadget::Event::mTime.

00076 {
00077    // We have already read the type in EventWindow to decide
00078    // if we should construct a KeyEvent or a MouseEvent
00079    //mType = reader->readUint16();
00080 
00081    // De-Serialize all member variables
00082    mKey = (gadget::Keys)reader->readUint32();
00083    mModifierMask = reader->readUint32();
00084    mTime = reader->readUint64();
00085    mAsciiKey = reader->readUint8();
00086    return vpr::ReturnStatus::Succeed;
00087 }


Member Data Documentation

gadget::Keys gadget::KeyEvent::mKey [protected]
 

The actual key pressed.

Definition at line 128 of file KeyEvent.h.

Referenced by readObject, and writeObject.

int gadget::KeyEvent::mModifierMask [protected]
 

The mask of any modifiers in addition to mKey.

Definition at line 129 of file KeyEvent.h.

Referenced by readObject, and writeObject.

char gadget::KeyEvent::mAsciiKey [protected]
 

ASCCI representation of key pressed.

Definition at line 130 of file KeyEvent.h.

Referenced by readObject, and writeObject.


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:57 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002