The SimpleCxxLib package


#include "gevents.h"

class GKeyEvent : public GEvent

This event subclass represents a key event. Each key event records the event type along with two representations of the key. The getKeyChar function is more generally useful and returns the character after taking into account modifier keys. The getKeyCode function returns an integer identifying the key, which can be a function key as well as a standard key. The codes return by getKeyCode are listed in the KeyCodes enumeration.
Constructor
GKeyEvent(type, gw, keyChar, keyCode) Creates a GKeyEvent using the specified parameters.
Methods
getGWindow() Returns the graphics window in which this event occurred.
getKeyChar() Returns the character represented by the keystroke, taking the modifier keys into account.
getKeyCode() Returns the integer code associated with the key in the event.
toString() Converts the event to a human-readable representation of the event.

Constructor detail


GKeyEvent(EventType type, const GWindow & gw, int keyChar, int keyCode);
Creates a GKeyEvent using the specified parameters.

Usage:

GKeyEvent keyEvent(type, gw, keyChar, keyCode);

Method detail


GWindow getGWindow() const;
Returns the graphics window in which this event occurred.

Usage:

GWindow gw = e.getGWindow();

char getKeyChar() const;
Returns the character represented by the keystroke, taking the modifier keys into account. For example, if the user types the 'a' key with the shift key down, getKeyChar will return 'A'. If the key code in the event does not correspond to a character, getKeyChar returns the null character.

Usage:

char ch = e.getKeyChar();

int getKeyCode() const;
Returns the integer code associated with the key in the event.

Usage:

int key = getKeyCode();

string toString() const;
Converts the event to a human-readable representation of the event.

Usage:

string str = e.toString();