MenuPanel.st
changeset 2972 65841fbd0933
parent 2936 723062b99960
child 3092 a1dee282cab7
equal deleted inserted replaced
2971:453ac2ba069d 2972:65841fbd0933
  7376 !
  7376 !
  7377 
  7377 
  7378 shortcutKeyAsString
  7378 shortcutKeyAsString
  7379     "converts shortcutKey to a text object"
  7379     "converts shortcutKey to a text object"
  7380 
  7380 
  7381     |nm prefix shortcutKey|
  7381     |shortcutKey|
  7382 
  7382 
  7383     shortcutKey := menuItem shortcutKey.
  7383     shortcutKey := menuItem shortcutKey.
  7384 
  7384 
  7385     shortcutKey isNil ifTrue:[
  7385     shortcutKey isNil ifTrue:[
  7386         ^ nil
  7386         ^ nil
  7387     ].
  7387     ].
  7388 
       
  7389     shortcutKey isCharacter ifTrue:[
  7388     shortcutKey isCharacter ifTrue:[
  7390         nm := shortcutKey asString
  7389         ^ shortcutKey asString
  7391     ] ifFalse:[
  7390     ].
  7392         "/ this is somewhat complicated: we have the symbolic key at hand,
  7391     ^ menuPanel device shortKeyStringFor:shortcutKey.
  7393         "/ but want to show the untranslated (inverse keyBoardMapped) key & modifier
  7392 
  7394         "/ Ask the devices keyboardMap for the backtranslation.
  7393     "Modified: / 08-08-2006 / 15:46:24 / cg"
  7395 
       
  7396         nm := menuPanel device keyboardMap keyAtValue:shortcutKey ifAbsent:shortcutKey.
       
  7397         "/
       
  7398         "/ some modifier-key combination ?
       
  7399         "/
       
  7400         (nm startsWith:#Cmd) ifTrue:[
       
  7401             prefix := #Cmd.
       
  7402         ] ifFalse:[(nm startsWith:#Alt) ifTrue:[
       
  7403             prefix := #Alt.
       
  7404         ] ifFalse:[(nm startsWith:#Meta) ifTrue:[
       
  7405             prefix := #Meta.
       
  7406         ] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[
       
  7407             prefix := #Ctrl.
       
  7408         ]]]].
       
  7409         prefix notNil ifTrue:[
       
  7410             nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1))
       
  7411         ] ifFalse:[
       
  7412             nm := nm asString
       
  7413         ]
       
  7414     ].
       
  7415     ^ nm
       
  7416 
       
  7417     "Modified: / 17.7.1998 / 11:56:40 / cg"
       
  7418 !
       
  7419 
       
  7420 shortcutKeyPrefixFor:aModifier
       
  7421     "returns the prefix assigned to a modifier"
       
  7422 
       
  7423     |m|
       
  7424 
       
  7425     m := menuPanel device modifierKeyTopFor:aModifier.
       
  7426     m notNil ifTrue:[
       
  7427         ^ m , '-'
       
  7428     ].
       
  7429     ^ aModifier , '-'.
       
  7430 
       
  7431     "Modified: / 17.7.1998 / 11:56:46 / cg"
       
  7432 ! !
  7394 ! !
  7433 
  7395 
  7434 !MenuPanel::Item methodsFor:'selection'!
  7396 !MenuPanel::Item methodsFor:'selection'!
  7435 
  7397 
  7436 isSelected
  7398 isSelected
  7644 ! !
  7606 ! !
  7645 
  7607 
  7646 !MenuPanel class methodsFor:'documentation'!
  7608 !MenuPanel class methodsFor:'documentation'!
  7647 
  7609 
  7648 version
  7610 version
  7649     ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.426 2006-03-06 13:45:28 cg Exp $'
  7611     ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.427 2006-08-08 14:00:10 cg Exp $'
  7650 ! !
  7612 ! !
  7651 
  7613 
  7652 MenuPanel initialize!
  7614 MenuPanel initialize!