2922 |
2922 |
2923 "Created: / 21-07-2011 / 16:04:22 / cg" |
2923 "Created: / 21-07-2011 / 16:04:22 / cg" |
2924 ! |
2924 ! |
2925 |
2925 |
2926 shortKeyStringFor:symbolicOrRawKey |
2926 shortKeyStringFor:symbolicOrRawKey |
|
2927 "Obsolete: For given symbolic or raw key, return a user-friendly shortcut description string. |
|
2928 Examples: |
|
2929 #Find -> Ctrl+f (depending on your default) |
|
2930 #CtrlX -> Ctrl+X |
|
2931 |
|
2932 This method is used in menu panel (#shortcutKeyAsString) to display shortcuts in menus. |
|
2933 " |
|
2934 <resource: #obsolete> |
|
2935 |
|
2936 self obsoleteMethodWarning: 'Use #shortKeyStringFor:usingMap: instead'. |
|
2937 ^ self shortKeyStringFor: symbolicOrRawKey usingMap: self keyboardMap |
|
2938 |
|
2939 "Created: / 08-08-2006 / 15:45:38 / cg" |
|
2940 "Modified: / 08-02-2017 / 23:54:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2941 ! |
|
2942 |
|
2943 shortKeyStringFor:symbolicOrRawKey usingMap: kbdMap |
2927 "For given symbolic or raw key, return a user-friendly shortcut description string. |
2944 "For given symbolic or raw key, return a user-friendly shortcut description string. |
2928 Examples: |
2945 Examples: |
2929 #Find -> Ctrl+f (depending on your settings) |
2946 #Find -> Ctrl+f (depending mapping in `kbdMap` parameter) |
2930 #CtrlX -> Ctrl+X |
2947 #CtrlX -> Ctrl+X |
2931 |
2948 |
2932 This method is used in menu panel (#shortcutKeyAsString) to display shortcuts in menus. |
2949 This method is used in menu panel (#shortcutKeyAsString) to display shortcuts in menus. |
2933 " |
2950 " |
2934 |
2951 |
2936 |
2953 |
2937 "/ this is somewhat complicated: we have the symbolic key at hand, |
2954 "/ this is somewhat complicated: we have the symbolic key at hand, |
2938 "/ but want to know the untranslated (inverse keyBoardMapped) key & modifier |
2955 "/ but want to know the untranslated (inverse keyBoardMapped) key & modifier |
2939 "/ this is used in the menu, to show the shortCut key beside the items. |
2956 "/ this is used in the menu, to show the shortCut key beside the items. |
2940 |
2957 |
2941 untranslatedKeys := OrderedCollection new. |
2958 untranslatedKeys := kbdMap rawKeysForLogical: symbolicOrRawKey. |
2942 self keyboardMap keysAndValuesDo:[:k :v | v == symbolicOrRawKey ifTrue:[untranslatedKeys add:k]]. |
2959 untranslatedKeys isEmpty ifTrue:[ |
2943 untranslatedKeys size == 0 ifTrue:[ |
2960 "/ if its not an explicit command key (Ctrl-*, Alt-* or Cmd-*), |
2944 "/ if its not an explicit command key (Ctrl-*, Alt-* or Cmd-*), |
2961 "/ but a symbolic key, return nil. |
2945 "/ but a symbolic key, return nil. |
2962 (#('Cmd' 'Ctrl' 'Alt' 'Meta' 'Shift') |
2946 (#('Cmd' 'Ctrl' 'Alt' 'Meta' 'Shift') |
2963 contains:[:k | (symbolicOrRawKey startsWith:k) ]) |
2947 contains:[:k | (symbolicOrRawKey startsWith:k) ]) |
2964 ifFalse:[^ nil]. |
2948 ifFalse:[^ nil]. |
|
2949 |
2965 |
2950 "/ (aSymbolicKey startsWith:'Cmd') ifFalse:[ |
2966 "/ (aSymbolicKey startsWith:'Cmd') ifFalse:[ |
2951 "/ (aSymbolicKey startsWith:'Ctrl') ifFalse:[ |
2967 "/ (aSymbolicKey startsWith:'Ctrl') ifFalse:[ |
2952 "/ (aSymbolicKey startsWith:'Alt') ifFalse:[ |
2968 "/ (aSymbolicKey startsWith:'Alt') ifFalse:[ |
2953 "/ (aSymbolicKey startsWith:'Meta') ifFalse:[ |
2969 "/ (aSymbolicKey startsWith:'Meta') ifFalse:[ |
2956 "/ ]. |
2972 "/ ]. |
2957 "/ ]. |
2973 "/ ]. |
2958 "/ ]. |
2974 "/ ]. |
2959 "/ ]. |
2975 "/ ]. |
2960 "/ ]. |
2976 "/ ]. |
2961 untranslatedKey := symbolicOrRawKey. |
2977 untranslatedKey := symbolicOrRawKey. |
2962 ] ifFalse:[ |
2978 ] ifFalse:[ |
2963 untranslatedKeys size == 1 ifTrue:[ |
2979 untranslatedKeys size == 1 ifTrue:[ |
2964 untranslatedKey := untranslatedKeys first. |
2980 untranslatedKey := untranslatedKeys first. |
2965 ] ifFalse:[ |
2981 ] ifFalse:[ |
2966 "if there are multiple mappings, show the Ctrl or the F-key mapping" |
2982 "if there are multiple mappings, show the Ctrl or the F-key mapping" |
2967 untranslatedKey := untranslatedKeys |
2983 untranslatedKey := untranslatedKeys |
2968 detect:[:k |k startsWith:'Ctrl'] |
2984 detect:[:k |k startsWith:'Ctrl'] |
2969 ifNone:[ |
2985 ifNone:[ |
2970 untranslatedKeys |
2986 untranslatedKeys |
2971 detect:[:k |k startsWith:'F'] |
2987 detect:[:k |k startsWith:'F'] |
2972 ifNone:[untranslatedKeys first]]. |
2988 ifNone:[untranslatedKeys first]]. |
2973 ]. |
2989 ]. |
2974 ]. |
2990 ]. |
2975 |
2991 |
2976 "/ |
2992 "/ |
2977 "/ some modifier-key combination ? |
2993 "/ some modifier-key combination ? |
2978 "/ |
2994 "/ |
2979 (untranslatedKey startsWith:#Cmd) ifTrue:[ |
2995 (untranslatedKey startsWith:#Cmd) ifTrue:[ |
2980 prefix := #Cmd. |
2996 prefix := #Cmd. |
2981 ] ifFalse:[(untranslatedKey startsWith:#Alt) ifTrue:[ |
2997 ] ifFalse:[(untranslatedKey startsWith:#Alt) ifTrue:[ |
2982 prefix := #Alt. |
2998 prefix := #Alt. |
2983 ] ifFalse:[(untranslatedKey startsWith:#Meta) ifTrue:[ |
2999 ] ifFalse:[(untranslatedKey startsWith:#Meta) ifTrue:[ |
2984 prefix := #Meta. |
3000 prefix := #Meta. |
2985 ] ifFalse:[(untranslatedKey startsWith:#Ctrl) ifTrue:[ |
3001 ] ifFalse:[(untranslatedKey startsWith:#Ctrl) ifTrue:[ |
2986 prefix := #Ctrl. |
3002 prefix := #Ctrl. |
2987 ]]]]. |
3003 ]]]]. |
2988 |
3004 |
2989 prefix notNil ifTrue:[ |
3005 prefix notNil ifTrue:[ |
2990 |modifier rest| |
3006 |modifier rest| |
2991 |
3007 |
2992 modifier := self modifierKeyTopFor:prefix. |
3008 modifier := self modifierKeyTopFor:prefix. |
2993 modifier := (modifier ? prefix). |
3009 modifier := (modifier ? prefix). |
2994 rest := (untranslatedKey copyFrom:(prefix size + 1)). |
3010 rest := (untranslatedKey copyFrom:(prefix size + 1)). |
2995 rest isEmpty ifTrue:[^ modifier ]. |
3011 rest isEmpty ifTrue:[^ modifier ]. |
2996 modifier := modifier , (self shortKeyPrefixSeparator). |
3012 modifier := modifier , (self shortKeyPrefixSeparator). |
2997 ^ modifier , rest |
3013 ^ modifier , rest |
2998 ]. |
3014 ]. |
2999 ^ untranslatedKey |
3015 ^ untranslatedKey |
3000 |
3016 |
3001 " |
3017 " |
3002 Screen current shortKeyStringFor: #Find |
3018 Screen current shortKeyStringFor: #Find |
3003 Screen current shortKeyStringFor: #CtrlX |
3019 Screen current shortKeyStringFor: #CtrlX |
3004 Screen current shortKeyStringFor: #CursorLeft |
3020 Screen current shortKeyStringFor: #CursorLeft |
3005 " |
3021 " |
3006 |
3022 |
3007 "Created: / 08-08-2006 / 15:45:38 / cg" |
3023 "Created: / 08-02-2017 / 23:28:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3008 "Modified (comment): / 28-04-2014 / 10:04:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3009 ! ! |
3024 ! ! |
3010 |
3025 |
3011 !DeviceWorkstation methodsFor:'accessing-misc'! |
3026 !DeviceWorkstation methodsFor:'accessing-misc'! |
3012 |
3027 |
3013 defaultEventMask |
3028 defaultEventMask |