tim Rowledge uploaded a new version of Morphic to project The Trunk: http://source.squeak.org/trunk/Morphic-tpr.1067.mcz
==================== Summary ====================
Name: Morphic-tpr.1067 Author: tpr Time: 14 January 2016, 5:09:31.880065 pm UUID: 9f5c0b23-31d9-4698-99ba-588068d5e268 Ancestors: Morphic-mt.1066
Use the new Time class>eventMillisecondClock method to get a fake timestamp for places where we have to fake up an event and want to compare its timestamp with a real event.
=============== Diff against Morphic-mt.1066 ===============
Item was changed: ----- Method: HandMorph>>generateDropFilesEvent: (in category 'private events') ----- generateDropFilesEvent: evtBuf "Generate the appropriate mouse event for the given raw event buffer"
"Note: This is still in an experimental phase and will need more work"
| position buttons modifiers stamp numFiles dragType | stamp := evtBuf second. + stamp = 0 ifTrue: [stamp := Time eventMillisecondClock]. - stamp = 0 ifTrue: [stamp := Time millisecondClockValue]. dragType := evtBuf third. position := evtBuf fourth @ evtBuf fifth. buttons := 0. modifiers := evtBuf sixth. buttons := buttons bitOr: (modifiers bitShift: 3). numFiles := evtBuf seventh. dragType = 4 ifTrue: ["e.g., drop"
owner borderWidth: 0. ^DropFilesEvent new setPosition: position contents: numFiles hand: self]. "the others are currently not handled by morphs themselves" dragType = 1 ifTrue: ["experimental drag enter"
owner borderWidth: 4; borderColor: owner color asColor negated]. dragType = 2 ifTrue: ["experimental drag move"
]. dragType = 3 ifTrue: ["experimental drag leave"
owner borderWidth: 0]. ^nil!
Item was changed: ----- Method: HandMorph>>generateKeyboardEvent: (in category 'private events') ----- generateKeyboardEvent: evtBuf "Generate the appropriate mouse event for the given raw event buffer"
| buttons modifiers type pressType stamp keyValue | stamp := evtBuf second. + stamp = 0 ifTrue: [stamp := Time eventMillisecondClock]. - stamp = 0 ifTrue: [stamp := Time millisecondClockValue]. pressType := evtBuf fourth. pressType = EventKeyDown ifTrue: [type := #keyDown]. pressType = EventKeyUp ifTrue: [type := #keyUp]. pressType = EventKeyChar ifTrue: [type := #keystroke]. modifiers := evtBuf fifth. buttons := (modifiers bitShift: 3) bitOr: (lastMouseEvent buttons bitAnd: 7). type = #keystroke ifTrue: [keyValue := (self keyboardInterpreter nextCharFrom: Sensor firstEvt: evtBuf) asInteger] ifFalse: [keyValue := evtBuf third]. ^ KeyboardEvent new setType: type buttons: buttons position: self position keyValue: keyValue hand: self stamp: stamp. !
Item was changed: ----- Method: HandMorph>>generateMouseEvent: (in category 'private events') ----- generateMouseEvent: evtBuf "Generate the appropriate mouse event for the given raw event buffer"
| position buttons modifiers type trail stamp oldButtons evtChanged | evtBuf first = lastEventBuffer first ifTrue: ["Workaround for Mac VM bug, *always* generating 3 events on clicks"
evtChanged := false. 3 to: evtBuf size do: [:i | (lastEventBuffer at: i) = (evtBuf at: i) ifFalse: [evtChanged := true]]. evtChanged ifFalse: [^nil]]. stamp := evtBuf second. + stamp = 0 ifTrue: [stamp := Time eventMillisecondClock]. - stamp = 0 ifTrue: [stamp := Time millisecondClockValue]. position := evtBuf third @ evtBuf fourth. buttons := evtBuf fifth. modifiers := evtBuf sixth.
type := buttons = 0 ifTrue:[ lastEventBuffer fifth = 0 ifTrue: [#mouseMove] "this time no button and previously no button .. just mouse move" ifFalse: [#mouseUp] "this time no button but previously some button ... therefore button was released" ] ifFalse:[ buttons = lastEventBuffer fifth ifTrue: [#mouseMove] "button states are the same .. now and past .. therfore a mouse movement" ifFalse: [ "button states are different .. button was pressed or released" buttons > lastEventBuffer fifth ifTrue: [#mouseDown] ifFalse:[#mouseUp]. ]. ]. buttons := buttons bitOr: (modifiers bitShift: 3). oldButtons := lastEventBuffer fifth bitOr: (lastEventBuffer sixth bitShift: 3). lastEventBuffer := evtBuf. type == #mouseMove ifTrue: [trail := self mouseTrailFrom: evtBuf. ^MouseMoveEvent new setType: type startPoint: (self position) endPoint: trail last trail: trail buttons: buttons hand: self stamp: stamp]. ^MouseButtonEvent new setType: type position: position which: (oldButtons bitXor: buttons) buttons: buttons hand: self stamp: stamp!
Item was changed: ----- Method: HandMorph>>generateWindowEvent: (in category 'private events') ----- generateWindowEvent: evtBuf "Generate the appropriate window event for the given raw event buffer"
| evt | evt := WindowEvent new. evt setTimeStamp: evtBuf second. + evt timeStamp = 0 ifTrue: [evt setTimeStamp: Time eventMillisecondClock]. - evt timeStamp = 0 ifTrue: [evt setTimeStamp: Time millisecondClockValue]. evt action: evtBuf third. evt rectangle: (Rectangle origin: evtBuf fourth @ evtBuf fifth corner: evtBuf sixth @ evtBuf seventh ). ^evt!
Item was changed: ----- Method: MorphicEvent>>timeStamp (in category 'accessing') ----- timeStamp "Return the millisecond clock value at which the event was generated" + ^timeStamp ifNil:[timeStamp := Time eventMillisecondClock]! - ^timeStamp ifNil:[timeStamp := Time millisecondClockValue]!
Item was changed: ----- Method: MouseEvent>>asMouseMove (in category 'converting') ----- asMouseMove "Convert the receiver into a mouse move" + ^MouseMoveEvent new setType: #mouseMove startPoint: position endPoint: position trail: {position. position} buttons: buttons hand: source stamp: Time eventMillisecondClock! - ^MouseMoveEvent new setType: #mouseMove startPoint: position endPoint: position trail: {position. position} buttons: buttons hand: source stamp: Time millisecondClockValue.!
packages@lists.squeakfoundation.org