DeviceWorkstation.st
changeset 5778 9416217f347a
parent 5734 232e20790a17
child 5828 b77d25ec29ad
equal deleted inserted replaced
5777:8a5b6ccd5476 5778:9416217f347a
  2709     "set the keyboard map"
  2709     "set the keyboard map"
  2710 
  2710 
  2711     keyboardMap := aMap
  2711     keyboardMap := aMap
  2712 !
  2712 !
  2713 
  2713 
       
  2714 shortKeyPrefixSeparator
       
  2715     "the saparator shown between the shortcut modified (CTRL, CMD etc.)
       
  2716      and the actual character. I.e. makes a Ctrl+A"
       
  2717 
       
  2718     "/ used to be '-'
       
  2719     ^ '+'
       
  2720 
       
  2721     "Created: / 21-07-2011 / 16:04:22 / cg"
       
  2722 !
       
  2723 
  2714 shortKeyStringFor:aSymbolicKey
  2724 shortKeyStringFor:aSymbolicKey
  2715     |untranslatedKeys untranslatedKey prefix|
  2725     |untranslatedKeys untranslatedKey prefix|
  2716 
  2726 
  2717     "/ this is somewhat complicated: we have the symbolic key at hand,
  2727     "/ this is somewhat complicated: we have the symbolic key at hand,
  2718     "/ but want to know the untranslated (inverse keyBoardMapped) key & modifier
  2728     "/ but want to know the untranslated (inverse keyBoardMapped) key & modifier
  2719     "/ this is used in the menu, to show the shortCut key beside the items.
  2729     "/ this is used in the menu, to show the shortCut key beside the items.
  2720 
  2730 
  2721     untranslatedKeys := OrderedCollection new.
  2731     untranslatedKeys := OrderedCollection new.
  2722     self keyboardMap keysAndValuesDo:[:k :v | v == aSymbolicKey ifTrue:[untranslatedKeys add:k]].
  2732     self keyboardMap keysAndValuesDo:[:k :v | v == aSymbolicKey ifTrue:[untranslatedKeys add:k]].
  2723     untranslatedKeys size == 0 ifTrue:[
  2733     untranslatedKeys size == 0 ifTrue:[
  2724 	"/ if its not an explicit command key (Ctrl-*, Alt-* or Cmd-*),
  2734         "/ if its not an explicit command key (Ctrl-*, Alt-* or Cmd-*),
  2725 	"/ but a symbolic key, return nil.
  2735         "/ but a symbolic key, return nil.
  2726 	(aSymbolicKey startsWith:'Cmd') ifFalse:[
  2736         (aSymbolicKey startsWith:'Cmd') ifFalse:[
  2727 	    (aSymbolicKey startsWith:'Ctrl') ifFalse:[
  2737             (aSymbolicKey startsWith:'Ctrl') ifFalse:[
  2728 		(aSymbolicKey startsWith:'Alt') ifFalse:[
  2738                 (aSymbolicKey startsWith:'Alt') ifFalse:[
  2729 		    (aSymbolicKey startsWith:'Meta') ifFalse:[
  2739                     (aSymbolicKey startsWith:'Meta') ifFalse:[
  2730 			(aSymbolicKey startsWith:'Shift') ifFalse:[
  2740                         (aSymbolicKey startsWith:'Shift') ifFalse:[
  2731 			    ^ nil
  2741                             ^ nil
  2732 			].
  2742                         ].
  2733 		    ].
  2743                     ].
  2734 		].
  2744                 ].
  2735 	    ].
  2745             ].
  2736 	].
  2746         ].
  2737 	untranslatedKey := aSymbolicKey.
  2747         untranslatedKey := aSymbolicKey.
  2738     ] ifFalse:[
  2748     ] ifFalse:[
  2739 	untranslatedKeys size == 1 ifTrue:[
  2749         untranslatedKeys size == 1 ifTrue:[
  2740 	    untranslatedKey := untranslatedKeys first.
  2750             untranslatedKey := untranslatedKeys first.
  2741 	] ifFalse:[
  2751         ] ifFalse:[
  2742 	    "if there are multiple mappings, show the Ctrl or the F-key mapping"
  2752             "if there are multiple mappings, show the Ctrl or the F-key mapping"
  2743 	    untranslatedKey := untranslatedKeys
  2753             untranslatedKey := untranslatedKeys
  2744 				detect:[:k |k startsWith:'Ctrl']
  2754                                 detect:[:k |k startsWith:'Ctrl']
  2745 				ifNone:[
  2755                                 ifNone:[
  2746 				    untranslatedKeys
  2756                                     untranslatedKeys
  2747 					detect:[:k |k startsWith:'F']
  2757                                         detect:[:k |k startsWith:'F']
  2748 					ifNone:[untranslatedKeys first]].
  2758                                         ifNone:[untranslatedKeys first]].
  2749 	].
  2759         ].
  2750     ].
  2760     ].
  2751 
  2761 
  2752     "/
  2762     "/
  2753     "/ some modifier-key combination ?
  2763     "/ some modifier-key combination ?
  2754     "/
  2764     "/
  2755     (untranslatedKey startsWith:#Cmd) ifTrue:[
  2765     (untranslatedKey startsWith:#Cmd) ifTrue:[
  2756 	prefix := #Cmd.
  2766         prefix := #Cmd.
  2757     ] ifFalse:[(untranslatedKey startsWith:#Alt) ifTrue:[
  2767     ] ifFalse:[(untranslatedKey startsWith:#Alt) ifTrue:[
  2758 	prefix := #Alt.
  2768         prefix := #Alt.
  2759     ] ifFalse:[(untranslatedKey startsWith:#Meta) ifTrue:[
  2769     ] ifFalse:[(untranslatedKey startsWith:#Meta) ifTrue:[
  2760 	prefix := #Meta.
  2770         prefix := #Meta.
  2761     ] ifFalse:[(untranslatedKey startsWith:#Ctrl) ifTrue:[
  2771     ] ifFalse:[(untranslatedKey startsWith:#Ctrl) ifTrue:[
  2762 	prefix := #Ctrl.
  2772         prefix := #Ctrl.
  2763     ]]]].
  2773     ]]]].
  2764 
  2774 
  2765     prefix notNil ifTrue:[
  2775     prefix notNil ifTrue:[
  2766 	|modifier|
  2776         |modifier|
  2767 
  2777 
  2768 	modifier := self modifierKeyTopFor:prefix.
  2778         modifier := self modifierKeyTopFor:prefix.
  2769 	modifier := (modifier ? prefix) , '-'.
  2779         modifier := (modifier ? prefix) , (self shortKeyPrefixSeparator).
  2770 
  2780 
  2771 	^ modifier , (untranslatedKey copyFrom:(prefix size + 1))
  2781         ^ modifier , (untranslatedKey copyFrom:(prefix size + 1))
  2772     ].
  2782     ].
  2773     ^ untranslatedKey
  2783     ^ untranslatedKey
  2774 
  2784 
  2775     "Created: / 08-08-2006 / 15:45:38 / cg"
  2785     "Created: / 08-08-2006 / 15:45:38 / cg"
  2776 ! !
  2786 ! !
  8093 ! !
  8103 ! !
  8094 
  8104 
  8095 !DeviceWorkstation class methodsFor:'documentation'!
  8105 !DeviceWorkstation class methodsFor:'documentation'!
  8096 
  8106 
  8097 version
  8107 version
  8098     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.559 2011-03-24 12:43:06 stefan Exp $'
  8108     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.560 2011-07-21 14:04:47 cg Exp $'
  8099 !
  8109 !
  8100 
  8110 
  8101 version_CVS
  8111 version_CVS
  8102     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.559 2011-03-24 12:43:06 stefan Exp $'
  8112     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.560 2011-07-21 14:04:47 cg Exp $'
  8103 ! !
  8113 ! !
  8104 
  8114 
  8105 DeviceWorkstation initialize!
  8115 DeviceWorkstation initialize!