Shortcuts in SWT? (accelerators) [message #449470] |
Tue, 25 January 2005 09: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 15:17 |
Steve Northover Messages: 1636 Registered: July 2009 |
Senior Member |
|
|
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?
>
>
|
|
|
Re: Shortcuts in SWT? (accelerators) [message #449519 is a reply to message #449510] |
Tue, 25 January 2005 16:18 |
Eclipse User |
|
|
|
Originally posted by: olivier.larivain.criltechnology.com
Thank you very much!!!
I spent a lot of time on this, and I was starting to think that there there
was no issue to this problem.
while i'm here, i'll ask a few more questions about this :
Why this choice has been made?
How come toolbars can't have accelerators?
They work roughly the same as menus do, so have this difference?
"Steve Northover" <steve_northover@ca.ibm.com> a
|
|
|
|
Powered by
FUDForum. Page generated in 0.03045 seconds