EventMonitor.st
branchjv
changeset 17712 7ac1ffddb6cf
parent 17518 b7688f8c4d7a
child 18226 346376844040
--- a/EventMonitor.st	Mon Sep 11 14:52:26 2017 +0200
+++ b/EventMonitor.st	Thu Oct 12 00:22:53 2017 +0100
@@ -567,6 +567,79 @@
     "Modified: / 04-10-2006 / 13:09:23 / cg"
 !
 
+keyPress:key x:x y:y
+    | s rawKey binding |
+
+    self showEventTime.
+
+    s := 'KeyPress x:' , x printString , ' y:' , y printString.
+    s printOn:outputStream.
+
+    (key isMemberOf:Character) ifTrue:[
+        s := ' character key:' , key storeString
+             , ' (' , key asciiValue printString , ')'.
+    ] ifFalse:[
+        s := ' symbolic key:' , key storeString.
+        binding := device keyboardMap bindingForLogical:key.
+        binding isNil ifTrue:[
+            binding := device keyboardMap aliasesForLogical: key.
+        ].
+        binding notNil ifTrue:[
+            s := s , ' untranslated key:' , binding storeString
+        ].
+    ].
+    rawKey := (WindowGroup lastEventQuerySignal query) rawKey.
+    s := s , ' rawKey:' , rawKey storeString.
+
+    s printOn:outputStream.
+
+    key isCharacter ifTrue:[
+        outputStream nextPutAll:' '''.
+        key asString printOn:outputStream.
+        outputStream nextPutAll:''''.
+    ].
+    outputStream cr.
+
+    "Modified: / 04-10-2006 / 13:12:07 / cg"
+    "Modified: / 12-10-2017 / 00:15:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+keyRelease:key x:x y:y
+    |binding|
+
+    self showEventTime.
+
+    'KeyRelease x:' printOn:outputStream.
+    x printOn:outputStream.
+    ' y:' printOn:outputStream.
+    y printOn:outputStream.
+
+    (key isMemberOf:Character) ifTrue:[
+        key codePoint <= 16rFF ifTrue:[
+            ' character key:' printOn:outputStream.
+            key storeString printOn:outputStream.
+        ] ifFalse:[
+            ' unicode character utf8:' printOn:outputStream.
+            key asString utf8Encoded asByteArray hexPrintOn:outputStream.
+        ].
+        ' (' printOn:outputStream. key asciiValue printOn:outputStream. ')' printOn:outputStream
+    ] ifFalse:[
+        ' symbolic key:' printOn: outputStream. key storeString printOn:outputStream.
+        binding := device keyboardMap bindingForLogical:key.
+        binding isNil ifTrue:[
+            binding := device keyboardMap aliasesForLogical: key.
+        ].
+        binding notNil ifTrue:[
+            ' untranslated key:' printOn:outputStream. binding storeString printOn:outputStream
+        ]. 
+    ].
+
+    outputStream cr
+
+    "Modified: / 04-10-2006 / 13:09:27 / cg"
+    "Modified: / 12-10-2017 / 00:18:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 mapped
     self showEventTime.