Bindings

Identifier:
org.eclipse.ui.bindings

Since:
3.1

Description:

The org.eclipse.ui.bindings extension point is used to declare bindings and schemes. Schemes are sets of one or more bindings. A binding is a mapping between a certain group of conditions, some user input and a triggered command.

All bindings require a trigger of some kind, a context in which they are active and scheme in which they exist. If you're not sure which context to chose, then just leave it blank. It will default to "org.eclipse.ui.contexts.window" context. This context means that the binding will apply in any Eclipse main window. When the context becomes active, the binding will become active as well. Bindings from child contexts will override bindings from parent contexts. For more information about contexts, please see the org.eclipse.ui.contexts extension point.

If a binding does not define a command identifier, then it is a deletion marker. This means that if all the conditions are met, it will cancel any bindings with the same trigger in the same context. This mechanism can be used, for example, to change a binding on a particular platform.

One type of binding is a key binding (i.e., a keyboard shortcut). For example, binding Ctrl+C to Copy is considered a key binding. The trigger for a key binding is a sequence of key strokes.

A scheme is a group of these bindings into a set that the end user can select. For example, a user might want to use the default scheme, but they might also want an Emacs-style scheme or a Brief-style scheme.

Configuration Markup:

<!ELEMENT extension (scheme* , key* , sequenceModifier*)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED>


<!ELEMENT scheme EMPTY>

<!ATTLIST scheme

id          CDATA #REQUIRED

name        CDATA #REQUIRED

description CDATA #IMPLIED

parentId    IDREF #IMPLIED>

A scheme is a grouping of bindings that an end user can chose to use.

It is possible for schemes to inherit bindings from a parent scheme. This is intended to make it easier for plug-in developers to create customized binding sets. An active binding defined in a child scheme will always override an active binding in a parent scheme, if they have the same trigger. This technique is used to provide the Emacs scheme in the workbench.



<!ELEMENT key (parameter*)>

<!ATTLIST key

sequence  CDATA #REQUIRED

schemeId  IDREF #REQUIRED

contextId IDREF "org.eclipse.ui.contexts.window"

commandId IDREF #IMPLIED

platform  CDATA #IMPLIED

locale    CDATA #IMPLIED>

A binding between some keyboard input and the triggering of a command.



<!ELEMENT parameter EMPTY>

<!ATTLIST parameter

id    IDREF #IMPLIED

value CDATA #IMPLIED>

A parameter name and value that should be passed to the command when it is executed. This allows for the command to be qualified in some way. For example, a "Show View" command might accept the view id as a parameter.



<!ELEMENT sequenceModifier EMPTY>

<!ATTLIST sequenceModifier

find      CDATA #REQUIRED

replace   CDATA #REQUIRED

platforms CDATA #REQUIRED>

Sequence Modifiers transform the key bindings on this extension. If a keybinding defined in this extension starts with the 'find' string, it will replace that portion with the 'replace' string. This replacement happens either if the platform in the keybinding is one of the platform in the 'platforms' or the platform in keybinding is not specified, but the current platform is one of the platform specified in 'platforms'



Examples:

<extension
 point="org.eclipse.ui.bindings">
 <sequenceModifier
  find="M1+M2"
  replace="M2+M3"
  platforms="cocoa,carbon" />
 <key
  sequence="M2+F5"
  commandId="example.commandId"
  schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
  contextId="org.eclipse.ui.contexts.dialog" />
 <key
  sequence="M1+M2+8"
  commandId="another.example.commandId"
  schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
  contextId="org.eclipse.ui.contexts.window" />
 <key
  sequence="M2+F7"
  commandId="other.commandId"
  schemeId="default.id"
  contextId="org.eclipse.ui.contexts.dialog" />
 <scheme
  name="Default"
  description="Default shortcuts for Eclipse"
  id="default.id" />
</extension>
In this example, on win32 another.example.commandId would be bound to M1+M2+8, but on cocoa it would be bound to M2+M3+8.

API Information:

There is no public API for defining bindings. To try to achieve stability for the user, bindings are only defined through the extension points. If you are an RCP application, you should be able to override this behaviour in the WorkbenchAdvisor.

For bindings to work, you must have defined a command. For the binding to work, the command must have an active handler. Handlers can be registered programmatically; please see the org.eclipse.ui.handlers extension point.


Copyright (c) 2005,2009 IBM Corporation and others.
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html/ SPDX-License-Identifier: EPL-2.0