DisplayRootView.st
changeset 6574 34a582daa1a3
parent 6373 70df108aa81f
child 6616 9dad6d1245cc
child 6753 57fff98ba620
--- a/DisplayRootView.st	Mon Sep 22 11:06:27 2014 +0200
+++ b/DisplayRootView.st	Tue Sep 23 13:36:04 2014 +0200
@@ -152,6 +152,56 @@
     "ignored"
 ! !
 
+!DisplayRootView methodsFor:'hotkeys'!
+
+addHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil
+    "install a handler (which should implement keyPress:x:y:view:
+     and keyRelease:x:y:view: on aKey.
+     aKey should be a symbolic key (like #F2).
+     modifierMask may constraint the key to be only handled when a certain
+     modifier is pressed (use a bitOr combination of device ctrlModifierMask,
+     altModifierMask etc.) or nil, so the key is always treated as a hotkey"
+
+    self sensor addEventListener:handler.
+    device 
+        grabKey:aKey
+        modifier:optionalModifierMaskOrNil
+        window:self.
+
+    "
+     Display rootView sensor removeAllEventListeners.
+
+     Display rootView
+        addHotKeyHandler:[:ev |
+Transcript showCR:ev.
+            ev key = 'F3' ifTrue:[
+                Dialog information:'YES!!'.
+            ].
+            false.
+        ]
+        forKey:'F3'
+        modifierMask:nil
+    "
+!
+
+removeHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil
+    "install a handler (which should implement keyPress:x:y:view:
+     and keyRelease:x:y:view: on aKey.
+     aKey should be a symbolic key (like #F2).
+     modifierMask may constraint the key to be only handled when a certain
+     modifier is pressed (use a bitOr combination of device ctrlModifierMask,
+     altModifierMask etc.) or nil, so the key is always treated as a hotkey"
+
+    self sensor removeEventListener:handler.
+    device 
+        ungrabKey:aKey
+        modifier:optionalModifierMaskOrNil
+        window:self.
+
+    "
+    "
+! !
+
 !DisplayRootView methodsFor:'initialization & release'!
 
 initialize
@@ -228,6 +278,6 @@
 !DisplayRootView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DisplayRootView.st,v 1.42 2014-04-03 14:39:59 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DisplayRootView.st,v 1.43 2014-09-23 11:36:04 cg Exp $'
 ! !