Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Binding key to popupMenu objectContribution
Binding key to popupMenu objectContribution [message #262954] Wed, 21 July 2004 15:12 Go to next message
Eclipse UserFriend
I am trying to associate a key binding with an action contributed via an
object contribution (IResource) to relevant popup menu's.

The action ("com.foo.ui.popup.actions.CopyGuideURIToClipAction") is
defined inside the objectContribution and which also contains the menu
definition on which the action is shown.

I defined a command and a keyBinding and when I run this with tracing
the Workbench associates the key sequence correctly with the command but
can't find a handler.

The action contains a definitionId=<my command id> attribute but that
doesn't seem to suffice.

How can this be achieved?

KEYS >>> Listener.handleEvent(type = KeyDown, stateMask = 0x70000,
keyCode = 0x63, character = 0x3)
KEYS >>> WorkbenchKeyboard.press(potentialKeyStrokes = [ALT+CTRL+SHIFT+C])
KEYS >>> WorkbenchKeyboard.executeCommand(commandId =
'com.ibm.xtools.rasguides.ui.copy.URLToClipboard')
KEYS >>> not handled

Below is an excerpt from my plugin.xml. There is no additional code
trying to register the action somehow.

<extension
point="org.eclipse.ui.commands">
<command
name="%command.copyGuideURLToClipboard.name"
description="%command.copyGuideURLToClipboard.description"
categoryId="org.eclipse.ui.category.edit"
id="com.foo.ui.copy.URLToClipboard">
</command>
<keyBinding
keySequence="Ctrl+Alt+Shift+C"
command="com.foo.ui.copy.URLToClipboard"
configuration="org.eclipse.ui.defaultAcceleratorConfiguration "
contextId="org.eclipse.ui.contexts.window"
scope="org.eclipse.ui.globalScope"
>
</keyBinding>
</extension>


<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IResource"
id="com.foo.ui.IJavaElement.copyGuideURIToClip">
<menu
label="%GuideProjectMenu.label"
path="additions"
id="com.foo.uiMenu">
<separator name="group1"/>
<separator name="group2"/>
</menu>
<action
label="%GuideProject.ModelServerElement.copyGuideURIToClip.label "
class="com.foo.ui.popup.actions.CopyGuideURIToClipAction"
menubarPath="com.foo.uiMenu/group2"
definitionID="com.foo.ui.copy.URLToClipboard"
enablesFor="1"
id="com.foo.ui.popup.actions.CopyGuideURIToClipAction">
</action>
</objectContribution>
Re: Binding key to popupMenu objectContribution [message #263156 is a reply to message #262954] Thu, 22 July 2004 09:46 Go to previous message
Eclipse UserFriend
This is currently not possible (see bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=32979).

Michael

Henrich Kraemer wrote:

> I am trying to associate a key binding with an action contributed via an
> object contribution (IResource) to relevant popup menu's.
>
> The action ("com.foo.ui.popup.actions.CopyGuideURIToClipAction") is
> defined inside the objectContribution and which also contains the menu
> definition on which the action is shown.
>
> I defined a command and a keyBinding and when I run this with tracing
> the Workbench associates the key sequence correctly with the command but
> can't find a handler.
>
> The action contains a definitionId=<my command id> attribute but that
> doesn't seem to suffice.
>
> How can this be achieved?
>
> KEYS >>> Listener.handleEvent(type = KeyDown, stateMask = 0x70000,
> keyCode = 0x63, character = 0x3)
> KEYS >>> WorkbenchKeyboard.press(potentialKeyStrokes = [ALT+CTRL+SHIFT+C])
> KEYS >>> WorkbenchKeyboard.executeCommand(commandId =
> 'com.ibm.xtools.rasguides.ui.copy.URLToClipboard')
> KEYS >>> not handled
>
> Below is an excerpt from my plugin.xml. There is no additional code
> trying to register the action somehow.
>
> <extension
> point="org.eclipse.ui.commands">
> <command
> name="%command.copyGuideURLToClipboard.name"
> description="%command.copyGuideURLToClipboard.description"
> categoryId="org.eclipse.ui.category.edit"
> id="com.foo.ui.copy.URLToClipboard">
> </command>
> <keyBinding
> keySequence="Ctrl+Alt+Shift+C"
> command="com.foo.ui.copy.URLToClipboard"
> configuration="org.eclipse.ui.defaultAcceleratorConfiguration "
> contextId="org.eclipse.ui.contexts.window"
> scope="org.eclipse.ui.globalScope"
> >
> </keyBinding>
> </extension>
>
>
> <extension
> point="org.eclipse.ui.popupMenus">
> <objectContribution
> objectClass="org.eclipse.core.resources.IResource"
> id="com.foo.ui.IJavaElement.copyGuideURIToClip">
> <menu
> label="%GuideProjectMenu.label"
> path="additions"
> id="com.foo.uiMenu">
> <separator name="group1"/>
> <separator name="group2"/>
> </menu>
> <action
> label="%GuideProject.ModelServerElement.copyGuideURIToClip.label "
> class="com.foo.ui.popup.actions.CopyGuideURIToClipAction"
> menubarPath="com.foo.uiMenu/group2"
> definitionID="com.foo.ui.copy.URLToClipboard"
> enablesFor="1"
> id="com.foo.ui.popup.actions.CopyGuideURIToClipAction">
> </action>
> </objectContribution>
>
Previous Topic:Deadlock due to UI code being run from non-UI thread
Next Topic:date format of date variable
Goto Forum:
  


Current Time: Sun May 11 14:31:07 EDT 2025

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

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

Back to the top