Running Pharo on an IBM Thinkpad with a trackpoint input device, I was a bit disappointed, that the autoscroll feature does not work in Pharo (pressing Button-2 and moving the mouse pointer should scroll the window below the mouse pointer). I took it as an exercise and the attached code does what I want, but it does notfeel right (like not at the the right 'level'): Is there a place in the Morph hierarchy where such behavior changes could be plugged in?
Or did I overlook a preference setting ;) ?
Cheers, Chris
Object subclass: #InputEventFetcher
instanceVariableNames: 'eventHandlers fetcherProcess inputSemaphore
mousewheel ycoord'
classVariableNames: 'Default'
poolDictionaries: 'EventSensorConstants'
category: 'Kernel-Processes'
InputEventFetcher>> signalEvent: eventBuffer
"Signal the event buffer to all registered event handlers.
Handlers need make sure to copy the buffer or extract the data
otherwise, as the buffer will be reused."
self simulateMousewheel: eventBuffer.
self eventHandlers do: [:handler |
handler handleEvent: eventBuffer]
InputEventFetcher>> simulateMousewheel: eventBuffer
"MOusewheel up: 2 time 30 0 2 0 0 1
MOusewheel down: 2 time 31 0 2 0 0 1
"
| ycur keysym up down |
keysym := nil.
up := 30.
down := 31.
(eventBuffer at: 1) = 1
ifTrue:
[ "mouse event"
((eventBuffer at: 5) anyMask: 1)
ifTrue:
[ "yellow button down"
mousewheel
ifFalse:
[ "first time: do
nothing"
mousewheel := true.
ycoord := eventBuffer
at: 4 ]
ifTrue:
[ "handle movement"
ycur := eventBuffer at:
4.
ycur - ycoord > 1
ifTrue:
[
keysym := down.
ycoord
:= ycur ].
ycur - ycoord < -1
ifTrue:
[
keysym := up.
ycoord
:= ycur ].
keysym isNil
ifTrue:
[ "make
it a Null event"
eventBuffer at: 1 put: 0 ]
ifFalse:
[
eventBuffer at: 1 put: 2.
eventBuffer at: 3 put: keysym.
eventBuffer
replaceFrom: 4
to: 8
with: #(0 2 0 0 1) ] ] ]
ifFalse:
[ "yellowbutton up"
mousewheel := false ] ].
^ eventBuffer_______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
