When using actions, I find that the accelerator key is shown differently in a menu than it is in a toolbar. For example, using the code below the menu item correctly shows "F9", as does it's tooltip, but a button on a toolbar shows "Alt-R" as its tooltip. Interestingly, this new key also works to activate the action.

   private final class RunAction extends AbstractAction {

       public RunAction() {
           super();

           putValue(IAction.NAME, "Run");
           putValue(IAction.SHORT_DESCRIPTION, "Run the current project");
           putValue(IAction.MNEMONIC_KEY, new Integer('R'));
           putValue(IAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F9"));
ULCIcon icon = new ULCIcon(getClass().getResource("/images/run.png"));
           putValue(IAction.SMALL_ICON, icon);
       }

       public void actionPerformed(ActionEvent actionEvent) {
           // my stuff...
       }
   }

In other cases, I don't set the IAction.ACCELERATOR_KEY, but the tooltips on the buttons are set to varous values such as "Alt-NumPad ." I noticed that if I don't set the IAction.MNEMONIC_KEY, I get different results.

I tested this on 6.1 and also just on 6.1.1 using Windows XP.

Thanks for any insight you can give.

-Stuart Booth (Abacus Research)
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to