1
votes

My custom Eclipse editor overrides createAction, where it registers an IAction with the editor. Then, in editorContextMenuAboutToShow I add this action to the menu.

Everything works fine, in that the action appears on the context menu within the editor; and I'm able to invoke the action from the menu itself.

Now, I'd like to add a key binding for this action. So far, I've added three extensions to my plugin.xml: a command, a binding, and a context. I can actually see the command/binding/context show up in the keys preference.

As for binding the command to my action, I've passed the command id declared in plugin.xml as the parameter to setActionDefinitionId after creating the action itself in createActions.

Needless to say, the key binding doesn't invoke the action - hence this question. What steps am I missing?

1
i did manage to get this working, by the setting the contextId of my commands to org.eclipse.ui.contexts.window instead of the id to a context which i had defined.... the question then becomes how do i "bind" my context to my editor???biosbob

1 Answers

1
votes

In a TextEditor-based editor, I had to touch these places in order to provide an action with a key binding:

  • define a command, key binding and scope (as you did)

  • set the actionDefinitionId to match the command id (as you did)

  • after creating the action in createActions(), I had to call setAction( myAction.getActionDefinitionId(), myAction );

  • set the scope in initializeKeyBindingScopes() with setKeyBindingScopes( new String[]{ "org.example.myScope" } );

Does that help?