links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Last updated at 3:14 am UTC on 12 May 2018
copy of the class comment

EventSensor passes the events to HandMorph.

EventSensor is a replacement for InputSensor based on a set of (optional) event primitives. An EventSensor updates its state when events are received so that all state based users of Sensor (e.g., Sensor keyboard, Sensor leftShiftDown, Sensor mouseButtons) will work exactly as before, by moving the current VM mechanisms into EventSensor itself. An optional input semaphore is part of the new design. For platforms that support true asynchronous event notification the semaphore can be signaled to indicate pending events. However, since most platforms do not support asynchronous notifications about events EventSensor still has to poll every now and then.

Instance variables:
mouseButtons - mouse button state as replacement for primMouseButtons
mousePosition - mouse position as replacement for primMousePt
keyboardBuffer - keyboard input buffer
interruptKey - currently defined interrupt key
interruptSemaphore - the semaphore signaled when the interruptKey is detected
eventQueue - an optional event queue for event driven applications
inputProcess - the process receiving low-level events
inputSemaphore - the semaphore signaled by the VM if asynchronous event notification is supported

Class variables:
EventPollFrequency - the number of milliseconds to wait between polling for more events

Event format:
The current event format is very simple. Each event is recorded into an 8 element array. All events must provide some SmallInteger ID (the first field in the event buffer) and a time stamp (the second field in the event buffer), so that the difference between the time stamp of an event and the current time can be reported.

Currently, the following events are defined:

Null event
The Null event is returned when the ST side asks for more events but no more events are available.
[1] - event type 0
[2-8] - unused

Mouse event structure
Mouse events are generated when mouse input is detected.
[1] - event type 1
[2] - time stamp
[3] - mouse x position
[4] - mouse y position
[5] - button state; bitfield with the following entries:
1 - yellow (e.g., right) button
2 - blue (e.g., middle) button
4 - red (e.g., left) button
[all other bits are currently undefined]
[6] - modifier keys; bitfield with the following entries:
1 - shift key
2 - ctrl key
4 - (Mac specific) option key
8 - Cmd/Alt key
[all other bits are currently undefined]
[7] - reserved.
[8] - reserved.

Keyboard events
Keyboard events are generated when keyboard input is detected.
[1] - event type 2
[2] - time stamp
[3] - character code
For now the character code is in Mac Roman encoding.
[4] - press state; integer with the following meaning
0 - character
1 - key press (down)
2 - key release (up)
[5] - modifier keys (same as in mouse events)
[6] - reserved.
[7] - reserved.
[8] - reserved.