|
||
Keyboard and Pointer
|
|
|||||||||||||
INCHAR and NEXTKEY Keyboard and pointer events are handled in an event queue that is internal to SilverScreen. In a program, events are removed from the queue with the inchar function. The event may be a keystroke, a pointer movement, or a pointer button press. If the queue is empty when inchar is called, then the function waits until an event occurs.
A second function, nextkey , may be used to view the event that is at the front of the queue without removing this event. If the queue is empty, nextkey does not wait for an event to occur, but instead, returns 0.
The combination of nextkey and inchar can be used to clear the queue. First, nextkey checks to see if an event is in the queue. If so, then inchar is used to remove the event. Here is the code:
|
|
|||||||||||||
Pointer Functions Events handled in SilverScreen, both keys and pointer events, are defined in sskeys.h . This header file defines the function keys, the control keys, and the pointer button and motion events.
SilverC programs are able to monitor the location of the arrow and to determine its location. Here are the functions:
|
|
|||||||||||||
Pointer Modes The events received from the pointing device are dependent on a pointer mode that can be set with pointer_mode. There are three modes: 0, 1 and 2.
|
|
|||||||||||||
Example The following section illustrates the use of several of the pointer functions:
The pointer is placed in mode 2, located at position 20 of line 20, and made visible. The program then reads events with inchar , identifying Esc from the keyboard and the three mouse events. |
|
|||||||||||||
|