An accelerator scope is used to define the appropriate context for accelerator keys. The workbench defines two accelerator scopes:
The scope dictates when an accelerator set (in the active accelerator configuration) is considered active. The scope is declared in the accelerator set markup:
<extension point="org.eclipse.ui.acceleratorSets"> <acceleratorSet scopeId="org.eclipse.ui.globalScope" configurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> <accelerator key="Ctrl+F4||Ctrl+X Ctrl+K" id="org.eclipse.ui.file.close"> </accelerator> <accelerator key="Ctrl+Shift+F4||Ctrl+X Ctrl+C" id="org.eclipse.ui.file.closeAll"> </accelerator> <accelerator key="Ctrl+X Ctrl+S" id="org.eclipse.ui.file.save"> </accelerator> ...
How is the current scope determined? By default, the workbench operates in a global scope. When a text editor becomes active, it is responsible for resetting the scope to the text editor scope. This is all handled by the workbench and text editor code. Most plug-ins need only determine the appropriate scope for their accelerator sets when defining them.
When a plug-in defines an accelerator set, it usually assigns it to an existing accelerator scope. However, if your plug-in defines a new style of editor, it's possible that you'll also want to introduce a new scope for accelerator keys. For example, a multi-page editor may have different scopes for each page in the editor.
When you define your own scope, it is up to your plug-in to ensure that the proper scopes are set into the IKeyBindingService as appropriate for your editor. A complete discussion of how this works is beyond the scope (pun intended!) of this documentation. Refer to IKeyBindingService and its implementors for more detail.
Plug-ins define accelerator scopes using the org.eclipse.ui.acceleratorScopes extension point. The workbench markup for the global and text editor accelerator configurations is shown below:
<extension point="org.eclipse.ui.acceleratorScopes"> <acceleratorScope name="%GlobalAcceleratorScope.name" description="%GlobalAcceleratorScope.description" id="org.eclipse.ui.globalScope"> </acceleratorScope> <acceleratorScope name="%TextEditorAcceleratorScope.name" parentScope="org.eclipse.ui.globalScope" description="%TextEditorAcceleratorScope.description" id="org.eclipse.ui.textEditorScope"> </acceleratorScope> </extension>