typedef struct { GR_EVENT_TYPE type; GR_WINDOW_ID wid; GR_WINDOW_ID subwid; GR_COORD rootx; GR_COORD rooty; GR_COORD x; GR_COORD y; int buttons; int modifiers; GR_UNICODE uch; unsigned int special; GR_CHAR ch; unsigned char content; } GR_EVENT_KEYSTROKE;
The GR_EVENT_KEYSTROKE structure is used by nano-X to pass the application keyboard events.
The keystroke will be sent to the highest window that contains the mouse cursor and has selected to receive keystroke events, if that window is a decendant of the focus window. Otherwise the keystroke is sent to the focus window or it's highest ancestor that has selected to receive keystroke events.
Type | Name | Description |
---|---|---|
GR_EVENT_TYPE | type | The event type will be either a GR_EVENT_TYPE_KEY_DOWN or a GR_EVENT_TYPE_KEY_UP type. |
GR_WINDOW_ID | wid | The ID of the window that the keystroke event is being sent to. |
GR_WINDOW_ID | subwid | The ID of the window that the mouse is in. Generally this field will be the same as wid, but in some cases if the mouse event occurs in a decendant of wid, then this field indicates that child window. |
GR_COORD | rootx | The X coordinate of the mouse pointer relative to the root window. |
GR_COORD | rooty | The Y coordinate of the mouse pointer relative to the root window. |
GR_COORD | x | The X coordinate of the mouse pointer relative to the window wid. |
GR_COORD | y | The Y coordinate of the mouse pointer relative to the window wid. |
int | buttons | Indicates the mouse buttons that are being pressed. This field will be 0 if all buttons are released or a bitwise OR of GR_BUTTON_R, GR_BUTTON_M and/or GR_BUTTON_L if one or more buttons are pressed. |
int | modifiers | Indicates the status of the keyboard modifier keys. This field will be 0 if no modifiers are pressed, or a bitwise OR of one or more of GR_MODIFIER_CTRL, GR_MODIFIER_META, GR_MODIFIER_SHIFT, GR_MODIFIER_LOCK, GR_MODIFIER_NUMLOCK and/or GR_MODIFIER_SCROLLLOCK if one or more modifier keys is pressed. |
GR_UNICODE | uch | The key that caused the keystroke event. |
unsigned int | special | Special key sequences (see below). |
GR_CHAR | ch | The key that caused the keystroke event. |
unsigned char | content | Keystroke content flags (see below). |
These actions have not yet been implemented as of Nano-X revision 0.89pre6.
The goal is to tag each keystroke event with a set of content flags. These content flags will indicate what type of data is actually contained in the keystroke event structure. The following two tables shown typical key sequences. The first table shows just the A key being pressed. The following table shows the key sequence F10 A being pressed.
ch | uch | special | content |
---|---|---|---|
Esc | 0x001B | 0 | GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ |
[ | 0x005B | 0 | GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ |
2 | 0x0032 | 0 | GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ |
1 | 0x0031 | 0 | GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ |
~ | 0x007E | GR_SPECIAL_KEY_F10 | GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ GR_KEYSTROKE_CONTENT_SPECIAL |
A | 0x0041 | 0 | GR_KEYSTROKE_CONTENT_8BIT_PROPER GR_KEYSTROKE_CONTENT_UNICODE_PROPER |
If your application only supports 8 bit characters, you should ignore all keystrokes that do not have the GR_KEYSTROKE_CONTENT_8BIT_PROPER, GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ or GR_KEYSTROKE_CONTENT_SPECIAL flags set. The GR_EVENT_KEYSTROKE structure always has an 8 bit key code field. But in some environments if a unicode character that does not have an 8 bit equivalent is contained in the keystroke event, the ch field will contain garbage.
Content Flag Name | Description |
---|---|
GR_KEYSTROKE_CONTENT_8BIT_PROPER | The ch field contains an ASCII key code. |
GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ | The ch field contains an ASCII control sequence. |
GR_KEYSTROKE_CONTENT_UNICODE_PROPER | The uch field contains a unicode key code. |
GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ | The uch field contains a unicode control sequence. |
GR_KEYSTROKE_CONTENT_SPECIAL | The special field contains a special key (see below). |
Special Key Name | Description |
---|---|
GR_SPECIAL_KEY_NOSPECIAL | No special key preceeded this key. |
GR_SPECIAL_KEY_F1 | The F1 key. |
GR_SPECIAL_KEY_F2 | The F2 key. |
GR_SPECIAL_KEY_F3 | The F3 key. |
GR_SPECIAL_KEY_F4 | The F4 key. |
GR_SPECIAL_KEY_F5 | The F5 key. |
GR_SPECIAL_KEY_F6 | The F6 key. |
GR_SPECIAL_KEY_F7 | The F7 key. |
GR_SPECIAL_KEY_F8 | The F8 key. |
GR_SPECIAL_KEY_F9 | The F9 key. |
GR_SPECIAL_KEY_F10 | The F10 key. |
GR_SPECIAL_KEY_F11 | The F11 key. |
GR_SPECIAL_KEY_F12 | The F12 key. |
GR_SPECIAL_KEY_NUM0 | The 0 key on the number pad. |
GR_SPECIAL_KEY_NUM1 | The 1 key on the number pad. |
GR_SPECIAL_KEY_NUM2 | The 2 key on the number pad. |
GR_SPECIAL_KEY_NUM3 | The 3 key on the number pad. |
GR_SPECIAL_KEY_NUM4 | The 4 key on the number pad. |
GR_SPECIAL_KEY_NUM5 | The 5 key on the number pad. |
GR_SPECIAL_KEY_NUM6 | The 6 key on the number pad. |
GR_SPECIAL_KEY_NUM7 | The 7 key on the number pad. |
GR_SPECIAL_KEY_NUM8 | The 8 key on the number pad. |
GR_SPECIAL_KEY_NUM9 | The 9 key on the number pad. |
GR_SPECIAL_KEY_NUM_PERIOD | The . key on the number pad. |
GR_SPECIAL_KEY_NUM_ENTER | The Enter key on the number pad. |
GR_SPECIAL_KEY_NUM_PLUSS | The + key on the number pad. |
GR_SPECIAL_KEY_NUM_MINUS | The - key on the number pad. |
GR_SPECIAL_KEY_NUM_STAR | The * key on the number pad. |
GR_SPECIAL_KEY_NUM_SLASH | The / key on the number pad. |
GR_SPECIAL_KEY_ESC | The Esc key. |
GR_SPECIAL_KEY_TAB | The Tab key. |
GR_SPECIAL_KEY_INSERT | The Insert key. |
GR_SPECIAL_KEY_DELETE | The Delete key. |
GR_SPECIAL_KEY_BACKSPACE | The BackSpace key. |
GR_SPECIAL_KEY_PAGEUP | The PageUp key. |
GR_SPECIAL_KEY_PAGEDOWN | The PageDown key. |
GR_SPECIAL_KEY_HOME | The Home key. |
GR_SPECIAL_KEY_END | The End key. |
GR_SPECIAL_KEY_ARROW_LEFT | The left arrow key. |
GR_SPECIAL_KEY_ARROW_RIGHT | The right arrow key. |
GR_SPECIAL_KEY_ARROW_UP | The up arrow key. |
GR_SPECIAL_KEY_ARROW_DOWN | The down arrow key. |