Overview   Project   Class   Tree   Deprecated   Index 
CarnegieMellonGraphics
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

CarnegieMellonGraphics2
Class KeyboardEvent

   in CarnegieMellonGraphics.h

class KeyboardEvent

KeyboardEvents are generated whenever the user presses a key. KeyboardEvents operate in a manner very similar to that of MouseEvent. So in the interest of brevity, I won't repeat much of the similar information. As before, they use default parameters, so the user only need specify as much detail as they have interest in matching.

As before it is also, possible to simply extract the pertinent information from an event using the accessor membor fuctions.

So for example if the user simply wants to see if the "G" key has been pressed they can do the following:

  if(KeyboardEvent('g') == some_event)
    // do something

Note, that if they wanted a capital G they should do the following:

  if(KeyboardEvent('G') == some_event)
    // do something

rather than

  if(KeyboardEvent('g', KeyModifiers::SHIFT) == some_event)
    // do something

One final example would be if the user wants to detect if the Alt and Escape keys have been pressed simultaneously they would do:

  if(KeyboardEvent(NamedKey::ESCAPE, KeyModifiers::ALT) == some_event)
    // do something else

Note that on some platforms, certain keyboard and modifier combinations will a) be trapped by the operating system/window manager and will not be reported as having taken place or b) correspond to another ASCII value for example Control-A under Unix/X11 will not map to A with a control modifier


Constructor Summary
KeyboardEvent( const int key, const KeyModifiers km = KeyModifiers::ANY_MODIFIERS )
          Constructor for a keyboard event from a pair of parameters.
KeyboardEvent( const KeyboardEvent& ke )
          
KeyboardEvent()
          
 
Method Summary
 const KeyModifiers getModifiers() const
          Obtain the set of modifers active at the time of the event
 const int getValue() const
          Obtain the integer value cooresponding to the event
 bool operator!=( const KeyboardEvent& rhs ) const
          Comparison operators for inequality on keyboard events
 bool operator==( const KeyboardEvent& rhs ) const
          Comparison operators for equality on keyboard events
 

Constructor Detail

KeyboardEvent

public KeyboardEvent( const int key, const KeyModifiers km = KeyModifiers::ANY_MODIFIERS );
Constructor for a keyboard event from a pair of parameters.

KeyboardEvent

public KeyboardEvent( const KeyboardEvent& ke );

KeyboardEvent

public KeyboardEvent();


Method Detail

getModifiers

public const KeyModifiers getModifiers() const;
Obtain the set of modifers active at the time of the event

getValue

public const int getValue() const;
Obtain the integer value cooresponding to the event

operator!=

public bool operator!=( const KeyboardEvent& rhs ) const;
Comparison operators for inequality on keyboard events

operator==

public bool operator==( const KeyboardEvent& rhs ) const;
Comparison operators for equality on keyboard events

 Overview   Project   Class   Tree   Deprecated   Index 
CarnegieMellonGraphics
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD