ActiveHand method processEvents
Last updated at 4:38 pm UTC on 25 August 2016
An instance of HandMorph is kept in the global variable ActiveHand
The method #processEvents is part of the Morphic main event loop.
"Process user input events from the local input devices."
| evt evtBuf type hadAny |
["Meaning that we were invoked from within an event response.
Make sure z-order is up to date"
self mouseOverHandler processMouseOver: lastMouseEvent].
hadAny := false.
[(evtBuf := Sensor nextEvent) isNil] whileFalse:
[evt := nil. "for unknown event types"
type := evtBuf first.
type = EventTypeMouse
ifTrue: [evt := self generateMouseEvent: evtBuf].
type = EventTypeMouseWheel
ifTrue: [evt := self generateMouseWheelEvent: evtBuf].
type = EventTypeKeyboard
ifTrue: [evt := self generateKeyboardEvent: evtBuf].
type = EventTypeDragDropFiles
ifTrue: [evt := self generateDropFilesEvent: evtBuf].
type = EventTypeWindow
ifTrue:[evt := self generateWindowEvent: evtBuf].
"All other events are ignored"
(type ~= EventTypeDragDropFiles and: [evt isNil]) ifTrue: [^self].
["Finally, handle it"
self handleEvent: evt.
hadAny := true.
"For better user feedback, return immediately after a mouse event has been processed."
evt isMouse ifTrue: [^self]]].
"note: if we come here we didn't have any mouse events"
["No mouse events during this cycle. Make sure click states time out accordingly"
mouseClickState handleEvent: lastMouseEvent asMouseMove from: self].
["No pending events. Make sure z-order is up to date"
self mouseOverHandler processMouseOver: lastMouseEvent]