David T. Lewis uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-dtl.1681.mcz ==================== Summary ==================== Name: Morphic-dtl.1681 Author: dtl Time: 15 September 2020, 10:29:40.709583 pm UUID: ee5dc42a-7d85-4c8b-b9e0-618eae3df221 Ancestors: Morphic-dtl.1680 Use Sensor eventTimeNow for synthesized event times. =============== Diff against Morphic-dtl.1680 =============== 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 := Sensor eventTimeNow]. - stamp = 0 ifTrue: [stamp := Time eventMillisecondClock]. 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 := Sensor eventTimeNow]. - stamp = 0 ifTrue: [stamp := Time eventMillisecondClock]. 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 := Sensor eventTimeNow]. - stamp = 0 ifTrue: [stamp := Time eventMillisecondClock]. 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 nClicks: (evtBuf seventh ifNil: [0]) hand: self stamp: stamp! Item was changed: ----- Method: HandMorph>>generateMouseWheelEvent: (in category 'private events') ----- generateMouseWheelEvent: evtBuf "Generate the appropriate mouse wheel event for the given raw event buffer" | buttons modifiers deltaX deltaY stamp nextEvent | stamp := evtBuf second. + stamp = 0 ifTrue: [stamp := Sensor eventTimeNow]. - stamp = 0 ifTrue: [stamp := Time eventMillisecondClock]. deltaX := evtBuf third. deltaY := evtBuf fourth. buttons := evtBuf fifth. modifiers := evtBuf sixth. [(deltaX abs + deltaY abs < self class minimumWheelDelta) and: [(nextEvent := Sensor peekEvent) notNil and: [nextEvent first = evtBuf first and: [nextEvent fifth = evtBuf fifth and: [nextEvent sixth = evtBuf sixth] and: [nextEvent third isZero = evtBuf third isZero "both horizontal or vertical"]]]]] whileTrue: ["nextEvent is similar. Remove it from the queue, and check the next." nextEvent := Sensor nextEvent. deltaX := deltaX + nextEvent third. deltaY := deltaY + nextEvent fourth]. ^ MouseWheelEvent new setType: #mouseWheel position: self position delta: deltaX@deltaY 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: Sensor eventTimeNow]. - evt timeStamp = 0 ifTrue: [evt setTimeStamp: Time eventMillisecondClock]. 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 := Sensor eventTimeNow]! - ^timeStamp ifNil:[timeStamp := Time eventMillisecondClock]! |
Free forum by Nabble | Edit this page |