Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » JFace action accelerators interfering with typing
JFace action accelerators interfering with typing [message #671555] Wed, 18 May 2011 09:51 Go to next message
Patrick  is currently offline Patrick
Messages: 2
Registered: May 2011
Junior Member
I have an application with a lot of jface actions (on a toolbar and in a menu) with accelerators, some of them single keys (e.g. just 'A'). However, when typing, say renaming an object (not modally) they interfere because when you try to type an A the action with that accelerator is activated, plus the A is not typed.

Is there a way to disable them temporarily? Or maybe you have another solution? I searched around but couldn't find anything. Also, settings the accelerators to 0 temporarily doesn't work because that call doesn't seem to do anything after the action constructor.

Thank you in advance.
Re: JFace action accelerators interfering with typing [message #671621 is a reply to message #671555] Wed, 18 May 2011 14:01 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

In general, it's a best practice to not use single letters for accelerators, for exactly the problem you describe ... the OS gets first pass at the key press, and consumes it.

If this is a JFace app (as opposed to an RCP app) then I guess it's either accelerators, mnemonics, or set up the Binding system yourself.

1) To use mnemonics, include '&' in the MenuManager text and action text. Then accessing most main menu items is a 2 stroke key sequence, like ALT+F N for New.

2) If you want the accelerator change to be noticed, keep the ActionContributionItem for the action you place in the MenuManager. Then:

action.setAccelerator(0);
actionCI.update(IAction.TEXT)


3) Setting up the binding system (the last option) is much harder than either of the above 2 options.

PW


Re: JFace action accelerators interfering with typing [message #671834 is a reply to message #671621] Thu, 19 May 2011 06:38 Go to previous message
Patrick  is currently offline Patrick
Messages: 2
Registered: May 2011
Junior Member
Thank you, a very clear answer.

I'll try using the second option.
Previous Topic:Can (Should) TableViewer be extended?
Next Topic:Ctrl+1 key binding lost in 3.3 to 3.6 upgrade.
Goto Forum:
  


Current Time: Wed Sep 17 09:49:28 GMT 2014

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

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