Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Shortcuts in SWT? (accelerators)
Shortcuts in SWT? (accelerators) [message #449470] Tue, 25 January 2005 09:20 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Shortcuts in SWT? (accelerators) [message #449686 is a reply to message #449519] Fri, 28 January 2005 00:42 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
This decision was force by the operating systems. You can use mnemonics in
toolbars with text.

"Larivain Olivier" <olivier.larivain@criltechnology.com> wrote in message
news:ct5rh7$km2$1@www.eclipse.org...
> 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
Previous Topic:How to handle window closing event?
Next Topic:Double click activates other app?
Goto Forum:
  


Current Time: Fri Apr 26 09:42:47 GMT 2024

Powered by FUDForum. Page generated in 0.03045 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top