KeyboardMap.st
branchjv
changeset 8036 e248f3b96260
parent 8035 8bbd397fe321
child 8037 d01faa4c1b02
--- a/KeyboardMap.st	Thu May 11 22:03:21 2017 +0200
+++ b/KeyboardMap.st	Thu Feb 09 00:17:19 2017 +0000
@@ -264,6 +264,9 @@
      shortcut (alias). For primary shortcuts, please use
      #bindValue:to:
     "
+    (aliases includesKey: rawKey) ifTrue:[ 
+         Logger warning:'Trying to bind alias (%1) to a logical action (%2) which is already bound (to %3). Removing old alias.' with: rawKey with: logicalKey with: (aliases at: rawKey).
+    ]. 
 
     rawKey == logicalKey ifTrue:[
         aliases removeKey:rawKey ifAbsent:nil.
@@ -271,6 +274,7 @@
         aliases at:rawKey put:logicalKey
     ]
 
+    "Modified: / 12-05-2017 / 23:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 bindValue:logicalKey to:rawKey
@@ -281,14 +285,26 @@
      to the application (such as #Copy, #Cut etc.) 
      instead of physical ones (such as #AltC, #AltX)"
 
+    "/ Issue a warning if logical key is already bound to a shortcut
+    "/ to track possibly unwanted aliases. If you really want to
+    "/ bind an alias, use #bindAlias:to:
+
+    | binding |
+
+    binding := bindings keyAtValue: logicalKey.
+    binding notNil ifTrue:[ 
+        Logger warning:'Trying to bind shortcut (%1) to a logical action (%2) which is already bound (to %3). Removing old shortcut,' with: rawKey with: logicalKey with: binding.
+    ]. 
+    bindings removeKey: binding ifAbsent: nil.
+
     rawKey == logicalKey ifTrue:[
         bindings removeKey:rawKey ifAbsent:nil
     ] ifFalse:[
         bindings at:rawKey put:logicalKey
     ]
 
-    "Modified: 12.11.1996 / 10:30:56 / cg"
-    "Modified: / 11-05-2017 / 21:45:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-11-1996 / 10:30:56 / cg"
+    "Modified: / 12-05-2017 / 23:39:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 bindValue:logicalKey to:key1 followedBy:key2