Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1378.mcz ==================== Summary ==================== Name: Kernel-eem.1378 Author: eem Time: 4 March 2021, 3:03:26.648613 pm UUID: 670311c0-11d4-4449-8c70-61d25280506f Ancestors: Kernel-nice.1377 Use the class side methods of MouseEvent to compute the (incredibly annoying) conflation of mouse buttons and modifier keys in events. This is a necessary first step in increasing the number of mouse buttons to support modern gaming mice. =============== Diff against Kernel-nice.1377 =============== Item was changed: ----- Method: EventSensor>>commandKeyPressed (in category 'modifier keys') ----- commandKeyPressed "Answer whether the command key on the keyboard is being held down." + ^ self peekButtons anyMask: MouseEvent numButtons + 3! - ^ self peekButtons anyMask: 64! Item was changed: ----- Method: EventSensor>>controlKeyPressed (in category 'modifier keys') ----- controlKeyPressed "Answer whether the control key on the keyboard is being held down." + ^self peekButtons anyMask: (1 bitShift: MouseEvent numButtons + 1)! - ^ self peekButtons anyMask: 16! Item was changed: ----- Method: EventSensor>>processKeyboardEvent: (in category 'private-I/O') ----- processKeyboardEvent: evt "process a keyboard event, updating EventSensor state" - | charCode pressCode | "Never update keyboardBuffer if we have an eventQueue active" + mouseButtons := (mouseButtons bitAnd: MouseEvent anyButton) bitOr: ((evt at: 5) bitShift: MouseEvent numButtons). - mouseButtons := (mouseButtons bitAnd: 7) bitOr: ((evt at: 5) bitShift: 3). + (evt at: 3) ifNotNil: "extra characters not handled in MVC" + [:charCode| | pressCode | + (pressCode := evt at: 4) = EventKeyChar ifTrue: "key down/up not handled in MVC" + ["mix in modifiers" + keyboardBuffer nextPut: (charCode bitOr: ((evt at: 5) bitShift: 8))]]! - charCode := evt at: 3. - charCode = nil ifTrue:[^self]. "extra characters not handled in MVC" - pressCode := evt at: 4. - pressCode = EventKeyChar ifFalse:[^self]. "key down/up not handled in MVC" - "mix in modifiers" - charCode := charCode bitOr: ((evt at: 5) bitShift: 8). - keyboardBuffer nextPut: charCode.! Item was changed: ----- Method: EventSensor>>processMouseEvent: (in category 'private-I/O') ----- processMouseEvent: evt "process a mouse event, updating EventSensor state" | modifiers buttons mapped | mousePosition := (evt at: 3) @ (evt at: 4). buttons := evt at: 5. modifiers := evt at: 6. mapped := self mapButtons: buttons modifiers: modifiers. + mouseButtons := mapped bitOr: (modifiers bitShift: MouseEvent numButtons)! - mouseButtons := mapped bitOr: (modifiers bitShift: 3).! Item was changed: ----- Method: EventSensor>>processMouseWheelEvent: (in category 'private-I/O') ----- processMouseWheelEvent: evt "process a mouse wheel event, updating EventSensor state" | modifiers buttons mapped | mouseWheelDelta := mouseWheelDelta + ((evt at: 3) @ (evt at: 4)). buttons := evt at: 5. modifiers := evt at: 6. mapped := self mapButtons: buttons modifiers: modifiers. + mouseButtons := mapped bitOr: (modifiers bitShift: MouseEvent numButtons)! - mouseButtons := mapped bitOr: (modifiers bitShift: 3).! Item was changed: ----- Method: EventSensor>>shiftPressed (in category 'modifier keys') ----- shiftPressed "Answer whether the shift key on the keyboard is being held down." + ^ self peekButtons anyMask: (1 bitShift: MouseEvent numButtons)! - ^ self peekButtons anyMask: 8 - ! |
Note that, at some point, we might want to move both EventSensor and event classes (e.g. MouseEvent) into a common package. Because leaving it like this would make Kernel depending on Morphic. :-) I am still looking for a name (and overall responsibilities) for such a package... Best, Marcel
|
> On 2021-03-04, at 11:50 PM, Marcel Taeumel <[hidden email]> wrote: > > Note that, at some point, we might want to move both EventSensor and event classes (e.g. MouseEvent) into a common package. Because leaving it like this would make Kernel depending on Morphic. :-) A very, very, long time ago Andreas & I had Words about this matter. When I first wrote the event sensor stuff I left it as very Morphic related, which seemed reasonable at the time for a prototype. Andreas correctly, albeit rudely, pointed out that the basic mechanism should not tie to Morphic or indeed any other specific UI layer. I think we eventually worked that part out ok. One might argue that EventSensor and a few other classes should be moved into a category other than Kernel-Processes on grounds of not being really wanted for some postulated totally headless image. Thinking about this reminds me that it might be a good idea to merge in the keyboard state tracking that I made for NuScratch. Internalised into EventSensor might simplify it; and perhaps it is a good model for replacing the messy #peekButtons etc. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim The subjunctive would have walked into a bar, had it only known. |
Free forum by Nabble | Edit this page |