Key bindings in custom widgets [message #496814] |
Wed, 11 November 2009 08:29  |
Eclipse Guest Messages: 93 Registered: February 2013 Location: Vienna |
Member |
|
|
Hi,
I have a problem with my custom widget. A table-like widget listens to key events and handles the occurence of the enter-key. Unfortuanetly, one of my Eclipse commands has a binding to that key and therefore is invoked when enter-key is pressed in my widget. My widget can handle the key but it seems that there is no way to prevent the Eclipse command to be executed. Preventing is necessary for my application because the enter-key opens a cell editor in the table and my Eclipse command opens a dialog that obviously interrupts the user. Any ideas? It would be nice to have a key-binding "context" also in single widgets but as far as I know the context can only be set on workbench parts.
I thought that an action delegation like org.eclipse.ui.actions.TextActionHandler can solve the problem by redirecting the Eclipse command to the table but this does not ensure that any other Eclipse command is invoked on enter-key.
Best regards,
Steffen
|
|
|
|
|
Re: Key bindings in custom widgets [message #496879 is a reply to message #496814] |
Wed, 11 November 2009 11:02   |
Eclipse Guest Messages: 93 Registered: February 2013 Location: Vienna |
Member |
|
|
Thank you for your replies!
Quote: | You can switch contexts based upon the focus control using the focus service.
|
I'm not certain if i understand what the focus service does related to the problem: it provides the variable for focused control and the copy/cut/... command handlers use this variable to delegate to e.g. focused text widget's cut/copy/... methods?
If so, there is another problem: any command can be associated with the enter-key as shortcut (using preferences), not only the one I contribute (that maybe delegate to my custom widget if focused control is considered). How do I ensure that other Eclipse commands do not disturb the cell editing?
By the way, my company is using Eclipse 3.2 and therefore the focus service is not available.
I think a widget should have the possibility to handle keys before any Eclipse shortcuts are handled. As you said, Paul, this is not possible. I will have to find another solution.
Thanks again,
Steffen
|
|
|
|
|
Re: Key bindings in custom widgets [message #498353 is a reply to message #496887] |
Mon, 16 November 2009 09:47  |
Eclipse Guest Messages: 93 Registered: February 2013 Location: Vienna |
Member |
|
|
Cancle the event is not desired because the cell editor should open on ENTER.
Quote: | You can enabled/disable a special context and the closest one wins when
it comes to keybindings.
|
Did you mean the "activateContext(String contextId, Expression expression, boolean global)" method on a IContextService retrieved from the workbench which I can call on focus lost / gained events (I haven't tried out yet but focus event seems to be appropriate because I need it only when in the widget)? So, defining my own context (maybe by code) can overwrite the keybinding of ENTER to my command? Would that be a "nice" solution?
Thanks for reply,
Steffen
|
|
|
Powered by
FUDForum. Page generated in 0.09835 seconds