[Pharo-project] KeyboardEvent differences between platforms
In TextEditor>>initializeShiftCmdKeyShortcuts the shortcuts are set in a way that it creates three handlers for each shortcut to make it work xD. The main difference here is that in Linux, ubuntu 11.04 the Ctrl+a comes with the right keyCharacter, but in Windows and MacOS it does not :(. We've tested that on host OSs with friends :). I've captured the problem I'm experimenting so far and wrote down an ugly hack in this method. KeyboardEvent>>modifiedCharacter self flag: #hack. "Hack me. When Ctrl is pressed, the key ascii value is not right and we have to do this shit" ^(self controlKeyPressed and: [ (#(MacOSX Windows) includes: Smalltalk os current platformFamily) and: [ keyValue <= 26 ]]) ifTrue: [ (self keyValue + $a asciiValue - 1) asCharacter ] ifFalse: [ self keyCharacter ] But I'd like to replace that by: KeyboardEvent>>modifiedCharacter ^self keyCharacter :P Are there any technical reasons why the Sensor behaves like that? How difficult is it to make it work the same for all three vms? Thanks! Guille
Hi Guille, this is what i've captured by hooking up a GauchoWorld to listen to vm events. Below you can find the sequences of keyDown, KeyChar, KeyUp, that results from different keyboard presses, in both Mac and Win VM's. In short, when pressing 1. any modifier key WinVMs produce an DOWN and UP event, and MAC VM's dont produce anything. 2. a modified keystroke ( modifer + key ), WinVMS produce a DOWN,DOWN,CHAR,UP,UP, whilst MacVm's produce a DOWN,CHAR,UP. 3. regarding the content of the Control key presses, both WinVm's and MacVms, produce an incorrect value of the keychar when they announce the CHAR event. Not when they announce DOWN and UP. 4. On command, alt, shift both VM's produce the correct values on the CHAR event. Fernando pd1: I've didn't collect results for the Linux VM. pd2: DATA collected VM "Sensor Events" format: #(type stamp ascii type buttons unicode 0 1 ) -------------------------------------------------------------------------------------------- MAC OS X VM ----------------------------------------------------------------------- SINGLE Keystrokes Control: nothing Command: nothing Shift: nothing ----------------------------------------------------------------------- Modified KEYSTROKES Commandl+$f - Down, keyStroke, Up #(2 523126 3 1 8 0 0 1) #(2 523126 102 0 8 102 0 1) #(2 523126 3 2 8 0 0 1) Control+$c - Down #(2 156689 0 2 2 0 0 1) ALT+$a - Down, keyStroke, Up #(2 165404 0 1 4 0 0 1) #(2 165404 140 0 4 229 0 1) #(2 165483 0 2 4 0 0 1) SHIFT + $s, Down, KeyStroke,Up #(2 734260 1 1 1 0 0 1) #(2 734260 83 0 1 83 0 1) #(2 734362 1 2 1 0 0 1) ----------------------------------------------------------------------- Unmodified KEYSTROKES Right Arrow-down, keystroke,up #(2 2329743 125 1 0 0 0 1) #(2 2329743 31 0 0 31 0 1) #(2 2329838 125 2 0 0 0 1) -------------------------------------------------------------------------- WINDOWS VM Shift- Down and Up #(2 123006507 16 1 1 16 0 1) #(2 123007958 16 2 0 16 0 1) Control- Down and Up #(2 123110575 17 1 2 17 0 1) #(2 123111589 17 2 0 17 0 1) ALT- Down and Up #(2 123205408 18 1 8 18 0 1) #(2 123208201 18 2 0 18 0 1) Control+$a - Down, Down, keyStroke, Up, Up #(2 123584803 17 1 2 17 0 1) #(2 123585037 65 1 2 65 0 1) #(2 123585037 1 0 2 1 0 1) #(2 123585099 17 2 0 17 0 1) #(2 123585115 65 2 0 65 0 1) Control+$b - Down, Down, keyStroke, Up, Up #(2 126935049 17 1 2 17 0 1) #(2 126935377 66 1 2 66 0 1) #(2 126935377 2 0 2 2 0 1) #(2 126935439 66 2 2 66 0 1) #(2 126935501 17 2 0 17 0 1) Control+$h - Down, Down, keyStroke, Up, Up #(2 126503769 17 1 2 17 0 1) #(2 126503878 72 1 2 72 0 1) #(2 126503878 8 0 2 8 0 1) #(2 126503925 17 2 0 17 0 1) #(2 126504003 72 2 0 72 0 1) ALT+$h - Down, Down, keyStroke, Up, Up #(2 126738160 18 1 8 18 0 1) #(2 126738316 72 1 8 72 0 1) #(2 126738316 104 0 8 104 0 1) #(2 126738379 72 2 8 72 0 1) #(2 126738410 18 2 0 18 0 1) SHIFT+$h - Down, Down, keyStroke, Up, Up #(2 126866175 16 1 1 16 0 1) #(2 126866721 72 1 1 72 0 1) #(2 126866721 72 0 1 72 0 1) #(2 126866830 16 2 0 16 0 1) #(2 126866830 72 2 0 72 0 1) On Sun, Nov 6, 2011 at 3:07 PM, Guillermo Polito <guillermopolito@gmail.com> wrote:
In TextEditor>>initializeShiftCmdKeyShortcuts the shortcuts are set in a way that it creates three handlers for each shortcut to make it work xD.
The main difference here is that in Linux, ubuntu 11.04 the Ctrl+a comes with the right keyCharacter, but in Windows and MacOS it does not :(. We've tested that on host OSs with friends :).
I've captured the problem I'm experimenting so far and wrote down an ugly hack in this method.
KeyboardEvent>>modifiedCharacter    self flag: #hack.    "Hack me. When Ctrl is pressed, the key ascii value is not right and we have to do this shit"    ^(self controlKeyPressed and: [ (#(MacOSX Windows) includes: Smalltalk os current platformFamily) and: [ keyValue <= 26 ]])        ifTrue: [ (self keyValue + $a asciiValue - 1) asCharacter ]        ifFalse: [ self keyCharacter ]
But I'd like to replace that by:
KeyboardEvent>>modifiedCharacter    ^self keyCharacter
:P
Are there any technical reasons why the Sensor behaves like that? How difficult is it to make it work the same for all three vms?
Thanks! Guille
Fernando olivero-2 wrote:
1. any modifier key WinVMs produce an DOWN and UP event, and MAC VM's dont produce anything.
Where did you put your hook? In 1.3-rc with Jenkins Carbon JIT VM, InputEventSensor>>handleEvent: sees #(1 102468 341 741 0 8 0 1) "Cmd pressed" #(1 102704 341 741 0 0 0 1) "Cmd unpressed" #(1 103210 341 741 0 4 0 1) "Alt pressed" #(1 103456 341 741 0 0 0 1) "Alt unpressed" #(1 105053 341 741 0 2 0 1) "Ctrl pressed" #(1 105215 341 741 0 0 0 1) "Ctrl unpressed" but they're classified as mouse events (first element). See also http://forum.world.st/Task-List-td4014056.html Sean -- View this message in context: http://forum.world.st/KeyboardEvent-differences-between-platforms-tp3995799p... Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
participants (3)
-
Fernando Olivero -
Guillermo Polito -
Sean P. DeNigris