public interface IFocusService
This service provides 2 variables, activeFocusControl (a Control) and activeFocusControlId (the ID registered with the service).
You can use this service to provide default cut/copy/paste/selectAll for specific text controls outside of the normal workbench part lifecycle, like a control contributed to the trim. For example:
<handler class="org.eclipse.ui.internal.handlers.WidgetMethodHandler:paste" commandId="org.eclipse.ui.edit.paste"> <activeWhen> <with variable="activeFocusControlId"> <equals value="org.eclipse.ui.tests.focusText"/> </with> </activeWhen> </handler>
This service can be acquired from your service locator:
IFocusService service = (IFocusService) getSite().getService(IFocusService.class);
ISources
Modifier and Type | Field and Description |
---|---|
static String |
COPY_HANDLER
Use the value to provide default copy behaviour in a handler element
class attribute.
|
static String |
CUT_HANDLER
Use the value to provide default cut behaviour in a handler element class
attribute.
|
static String |
PASTE_HANDLER
Use the value to provide default paste behaviour in a handler element
class attribute.
|
static String |
SELECT_ALL_HANDLER
Use the value to provide default select all behaviour in a handler
element class attribute.
|
Modifier and Type | Method and Description |
---|---|
void |
addFocusTracker(Control control,
String id)
A Control for which the service will track focus.
|
void |
removeFocusTracker(Control control)
No longer track focus events for this control.
|
static final String COPY_HANDLER
static final String PASTE_HANDLER
static final String CUT_HANDLER
static final String SELECT_ALL_HANDLER
void addFocusTracker(Control control, String id)
A control must only be registered once, but different controls can be registered with the same ID. Expressions evaluated against the activeFocusControlId would then be true for all of the controls thus registered.
We will remove ourselves as a listener when the Control is disposed.
control
- the control. Must not be null
. If the control
is already registered with this service this call is a no-op.id
- an ID for this control. Must not be null
.void removeFocusTracker(Control control)
control
- the control registered with the service. Must not be
null
.
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.