--- a/DeviceWorkstation.st Tue Aug 08 12:04:57 2006 +0200
+++ b/DeviceWorkstation.st Tue Aug 08 15:59:51 2006 +0200
@@ -2606,12 +2606,69 @@
"return the keyboard map"
^ keyboardMap
+
+ "
+ Screen current keyboardMap
+ "
+
+ "Modified: / 08-08-2006 / 15:00:35 / cg"
!
keyboardMap:aMap
"set the keyboard map"
keyboardMap := aMap
+!
+
+shortKeyStringFor:aSymbolicKey
+ |untranslatedKeys untranslatedKey prefix pref|
+
+ "/ this is somewhat complicated: we have the symbolic key at hand,
+ "/ but want to know the untranslated (inverse keyBoardMapped) key & modifier
+ "/ this is used in the menu, to show the shortCut key beside the items.
+
+ untranslatedKeys := OrderedCollection new.
+ self keyboardMap keysAndValuesDo:[:k :v | v == aSymbolicKey ifTrue:[untranslatedKeys add:k]].
+ untranslatedKeys size == 0 ifTrue:[
+ untranslatedKey := aSymbolicKey.
+ ] ifFalse:[
+ untranslatedKeys size == 1 ifTrue:[
+ untranslatedKey := untranslatedKeys first.
+ ] ifFalse:[
+ "if there are multiple mappings, show the Ctrl or the F-key mapping"
+ untranslatedKey := untranslatedKeys
+ detect:[:k |k startsWith:'Ctrl']
+ ifNone:[
+ untranslatedKeys
+ detect:[:k |k startsWith:'F']
+ ifNone:[untranslatedKeys first]].
+ ].
+ ].
+
+ "/
+ "/ some modifier-key combination ?
+ "/
+ (untranslatedKey startsWith:#Cmd) ifTrue:[
+ prefix := #Cmd.
+ ] ifFalse:[(untranslatedKey startsWith:#Alt) ifTrue:[
+ prefix := #Alt.
+ ] ifFalse:[(untranslatedKey startsWith:#Meta) ifTrue:[
+ prefix := #Meta.
+ ] ifFalse:[(untranslatedKey startsWith:#Ctrl) ifTrue:[
+ prefix := #Ctrl.
+ ]]]].
+
+ prefix notNil ifTrue:[
+ |modifier|
+
+ modifier := self modifierKeyTopFor:prefix.
+ modifier := (modifier ? prefix) , '-'.
+
+ ^ modifier , (untranslatedKey copyFrom:(prefix size + 1))
+ ].
+ ^ untranslatedKey
+
+ "Created: / 08-08-2006 / 15:45:38 / cg"
! !
!DeviceWorkstation methodsFor:'accessing-misc'!
@@ -7566,7 +7623,7 @@
!DeviceWorkstation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.500 2006-03-06 08:52:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.501 2006-08-08 13:59:51 cg Exp $'
! !
DeviceWorkstation initialize!