Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Parameterized commands and key bindings
Parameterized commands and key bindings [message #734164] Thu, 06 October 2011 21:46 Go to next message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
I cannot get the key bindings to show in the drop-down menu that is attached to a toolbar button. If I remove parameters
from my commands, the key shortcuts show in the menu. Put the parameters back, and the bindings disappear. Can anyone
spot anything wrong in the following code?

Commands:

<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="com.abc.ui.handler.PickModePulldownHandler"
description="Description"
id="com.abc.ui.handlers.defaultpickmode"
name="name">
</command>

<command
defaultHandler="com.abc.ui.handler.PickModeHandler"
description="Description"
id="com.abc.ui.handlers.pickmode.deletepick"
name="Delete">
returnTypeId="com.abc.ui.pickmode.commandParameterType">
<commandParameter
id="PICK_MODE_PARAMETER"
name="FBPick mode parameter"
optional="false"
typeId="com.abc.ui.pickmode.commandParameterType"
values="com.abc.ui.handler.PickModeParameterValues">
</commandParameter>
</command>
</extension>

(the first command to be used in the toolbar button, the second command contributes to the attached drop-down menu).

Menus:

<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=abc_editor_additions">
<toolbar id="com.abc.ui.handlers.pickmode.toolbar">
<command
commandId="com.abc.ui.handlers.defaultpickmode"
id="com.abc.ui.handlers.pickmode.pulldown"
icon="icons/elcl16/pickmodeboth.gif"
style="pulldown">
</command>
</toolbar>
</menuContribution>

<menuContribution
locationURI="menu:com.abc.ui.handlers.pickmode.pulldown?after=additions">
<command
commandId="com.abc.ui.handlers.pickmode.deletepick"
label="Delete"
icon="icons/elcl16/pickmodedelete.gif"
style="radio">
<parameter
name="PICK_MODE_PARAMETER"
value="DELETE">
</parameter>
</menuContribution>
</extension>

(the first menu contribution is the toolbar button, the second is the drop-down list item)

And finally the binding:

<extension
point="org.eclipse.ui.bindings">
<key
sequence="D"
contextId="com.abc.ui.editor.FBEditor"
commandId="com.abc.ui.handlers.pickmode.deletepick"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>

As I said before, take the <commandParameter> element away, and the binding shows in the drop-down list as the key
shortcut (the letter D).

Is this a known issue, or did I screw it up somewhere?

Thanks,

Alex Molochnikov
Fugro Geoservices Ltd.
Re: Parameterized commands and key bindings [message #753483 is a reply to message #734164] Thu, 27 October 2011 12:48 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

1) the keybinding takes the parameter into account. If your command menu item has a parameter X, you would only see a keybinding for that command with the parameter set to X. A keybinding for the command with no parameter is treated as a different keybinding.

2) are you looking for a mnemonic instead of a keybinding? Like having the menu item label Delete have it's 'D' underlined?

PW


Previous Topic:dynamic context menu
Next Topic:How to add parameters to CommandContributionItemParameter
Goto Forum:
  


Current Time: Fri Apr 26 04:52:57 GMT 2024

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

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

Back to the top