[SOLVED] Key Binding only works when menu visible? [message #988232] |
Thu, 29 November 2012 02:44 |
Jim Klo Messages: 49 Registered: September 2012 |
Member |
|
|
Hi,
I've got a multi-plugin rcp project that builds upon a custom editor.
Plugin 1: Editor
Plugin 2: Query Viewer + Query Command
I want to be able to add a key binding to execute the query command when after a selection is made in the editor.
Right now I have a popup menu that contains the command to execute (with a key binding visible). The key binding only seems to work when the popup is open and visible! How can I enable my command so that all I need to do is select text, and press the key binding?
Here is the relevant snippets from Plugin 2's plugin.xml:
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.sri.rave.flora.query.command.execute_query"
contextId="org.eclipse.ui.textEditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+y">
</key>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="com.sri.rave.flora.query.commands.ExecuteQueryCommand"
id="com.sri.rave.flora.query.command.execute_query"
name="Execute Query">
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
locationURI="popup:#TextEditorContext?after=additions">
<command
commandId="com.sri.rave.flora.query.command.execute_query"
icon="icons/query.png"
label="Execute Query"
style="push">
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="net.sourceforge.flora.eclipse.menu"
label="Flora">
<command
commandId="com.sri.rave.flora.query.command.execute_query"
icon="icons/query.png"
label="Execute Query"
style="push">
</command>
</menu>
</menuContribution>
</extension>
Thanks,
- Jim
[Updated on: Fri, 30 November 2012 17:53] Report message to a moderator
|
|
|
|
[SOLVED] Key Binding only works when menu visible? [message #988625 is a reply to message #988564] |
Fri, 30 November 2012 17:52 |
Jim Klo Messages: 49 Registered: September 2012 |
Member |
|
|
So:
1. It's relying upon the defaultHandler in the command declaration below.
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="com.sri.rave.flora.query.commands.ExecuteQueryCommand"
id="com.sri.rave.flora.query.command.execute_query"
name="Execute Query">
</command>
</extension>
2. I don't think contexts had any impact here, as regardless of what I set it to (whether it be the default org.eclipse.ui.window or one that I create), I still had the same behavior. Key binding works in visible menu, and nowhere else.
That said I believe I found the problem, since I got it working - sadly it is because of the VERY POORLY WRITTEN DOCUMENTATION FOR BINDINGS!!! It's not that te information isn't there, it's just so wordy that requirements aren't explicit and clear, thus it's easy to miss little details.
Within this block the only thing I change?
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.sri.rave.flora.query.command.execute_query"
contextId="org.eclipse.ui.textEditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+y">
</key>
</extension>
should have been
I'm guessing that something in the handler within the menus deals with the lowercase version, but globally it only works if uppercase.
Note the documentation is extremely wordy - and I missed the one little mention about 'in uppercase', which is somewhat mentioned like an aside!
[Updated on: Fri, 30 November 2012 17:52] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03670 seconds