Shortcuts in SWT? (accelerators) [message #449470] |
Tue, 25 January 2005 04:20  |
Eclipse User |
|
|
|
Originally posted by: olivier.larivain.criltechnology.com
Hi,
I'm actually trying to add shortcuts to my standalone SWT application.
The only I found about shortcuts in the documentations seems to refer to
Menu and MenuItem, but I just couldn't get any
confirmation about this.
I'm not using menus, but toolbars instead.
Though, I tried the following in the actions added to the toolbar
(AbstractAction being some kind of convenience superclass, subclassing
org.eclipse.jface.action.Action :
public class DisconnectAction extends AbstractAction {
public DisconnectAction(ApplicationWindow mainWindow) {
super(mainWindow);
setText(TEXT);
setToolTipText(TOOL_TIP_TEXT);
setImageDescriptor(ImageProvider.getInstance(GuiProperties.I MAGES_DIR).getIm
ageDescriptor(IMAGE_NAME));
setEnabled(true);
setAccelerator(convertAccelerator("Ctrl+q"));
}
}
All actions look the same, and are added to a ToolBarManager.
Of course, this doesn't work.. :( Nothing happens when I press Ctrl+q
I googlized the more i could, I still don't understand how shortcuts works
in SWT.
Could anyone please help me out?
|
|
|
Re: Shortcuts in SWT? (accelerators) [message #449510 is a reply to message #449470] |
Tue, 25 January 2005 10:17   |
Eclipse User |
|
|
|
Shortcuts (called Accelerators in SWT) are always properties of MenuItems.
They are global to a window in the same way that a menu bar is global. If
you want accelerators without MenuItems, then you need to either hook
SWT.KeyDown or filter key events these events in Display. The later is what
Eclipse does to implement accelerators.
"Larivain Olivier" <olivier.larivain@criltechnology.com> wrote in message
news:ct531n$asd$1@www.eclipse.org...
> Hi,
> I'm actually trying to add shortcuts to my standalone SWT application.
> The only I found about shortcuts in the documentations seems to refer to
> Menu and MenuItem, but I just couldn't get any
> confirmation about this.
> I'm not using menus, but toolbars instead.
>
> Though, I tried the following in the actions added to the toolbar
> (AbstractAction being some kind of convenience superclass, subclassing
> org.eclipse.jface.action.Action :
>
> public class DisconnectAction extends AbstractAction {
>
> public DisconnectAction(ApplicationWindow mainWindow) {
> super(mainWindow);
> setText(TEXT);
> setToolTipText(TOOL_TIP_TEXT);
>
>
setImageDescriptor(ImageProvider.getInstance(GuiProperties.I MAGES_DIR).getIm
> ageDescriptor(IMAGE_NAME));
> setEnabled(true);
> setAccelerator(convertAccelerator("Ctrl+q"));
> }
>
> }
>
> All actions look the same, and are added to a ToolBarManager.
>
> Of course, this doesn't work.. :( Nothing happens when I press Ctrl+q
> I googlized the more i could, I still don't understand how shortcuts works
> in SWT.
>
> Could anyone please help me out?
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05840 seconds