public class FocusGuardInputMode extends Object implements IInputMode
IInputMode
that can be added to a MultiplexingInputMode
to suppress other modes from doing unwanted
things if the control has just become focused.
This mode requests the input mutex once the canvas gains focus. It returns the mutex after the mode has regained focus
and the mouse has been clicked or 100 milliseconds have passed. This mode should be registered with the MultiplexingInputMode
using the MultiplexingInputMode.add(IInputMode)
method and a large priority number (e.g.
1000
). So that other modes don't receive the input mutex once this one has released the mutex.
This mode is Exclusive
by default.
Constructor and Description |
---|
FocusGuardInputMode()
Creates a new instance of this mode.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Called by the client to unconditionally cancel all editing.
|
protected ConcurrencyController |
getController()
Returns the installed
Controller . |
Cursor |
getGuardCursor()
Gets the
Cursor that will be shown during active guards. |
IInputModeContext |
getInputModeContext()
Returns the context instance this mode is currently installed in or
null if this instance is not installed. |
int |
getPriority()
The priority of this input mode.
|
void |
install(IInputModeContext context,
ConcurrencyController controller)
Installs this mode into the given context that is provided by the canvas.
|
boolean |
isEnabled()
Gets the enabled state of this input mode.
|
protected void |
onCanceled()
Called after
cancel() has been called. |
protected void |
onConcurrencyControllerActivated()
|
protected void |
onConcurrencyControllerDeactivated()
|
protected void |
onStopped()
Called after
stop() has been called. |
void |
setEnabled(boolean value)
Sets the enabled state of this input mode.
|
void |
setGuardCursor(Cursor value)
Sets the
Cursor that will be shown during active guards. |
void |
setPriority(int value)
The priority of this input mode.
|
boolean |
stop()
Called by the client in order to stop a current editing progress.
|
void |
uninstall(IInputModeContext context)
Uninstalls this mode from the given context.
|
public FocusGuardInputMode()
public void cancel()
IInputMode
This will be called prior to the uninstalling of this instance.
In order to stop an active input mode manually, client code should use the following idiom:
cancel
in interface IInputMode
protected final ConcurrencyController getController()
Controller
.public final Cursor getGuardCursor()
Cursor
that will be shown during active guards.
The default is Arrow
setGuardCursor(Cursor)
public final IInputModeContext getInputModeContext()
IInputMode
null
if this instance is not installed.
Note that this instance should not be passed down to subordinate modes or instances. Instead a corresponding context
that has this instance set as the ParentInputMode
should be used.
getInputModeContext
in interface IInputMode
public final int getPriority()
IInputMode
The priority will influence the order in which the modes will be installed
into the canvas control. The lower the priority value, the earlier it will be installed. If two modes are installed
using the same priority value, the first one will be installed earlier.
getPriority
in interface IInputMode
public void install(IInputModeContext context, ConcurrencyController controller)
In general a mode can only be installed into a single canvas at all times.
This method is called to initialize this instance. Subclasses should override this method to register the corresponding event handler delegates for the various input events they need to register with.
Overriding implementations should call the base implementation, first.
install
in interface IInputMode
context
- The context that this instance shall be installed into. The same instance will be passed to this instance during
IInputMode.uninstall(IInputModeContext)
. A reference to the context may be kept and queried during the time
the mode is installed.controller
- The Controller
for this mode.IInputMode.uninstall(IInputModeContext)
public boolean isEnabled()
Clients can use this property to disable or reenable this instance. This will set the Enabled
property of the installed Controller
so a disabled instance should never try to acquire the
input mutex.
setEnabled(boolean)
protected void onCanceled()
cancel()
has been called.
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
protected void onConcurrencyControllerActivated()
Active
property of the installed ConcurrencyController
has been set to true
.
Can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
protected void onConcurrencyControllerDeactivated()
Active
property of the installed ConcurrencyController
has been set to false
.
Can be overridden in subclasses to perform additional actions after the mode has been deactivated.
Overriding implementations should call the base implementation.
protected void onStopped()
stop()
has been called.
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
public void setEnabled(boolean value)
Clients can use this property to disable or reenable this instance. This will set the Enabled
property of the installed Controller
so a disabled instance should never try to acquire the
input mutex.
value
- The Enabled to set.isEnabled()
public final void setGuardCursor(Cursor value)
Cursor
that will be shown during active guards.
The default is Arrow
value
- The GuardCursor to set.getGuardCursor()
public final void setPriority(int value)
The priority will influence the order in which the modes will be installed
into the canvas control. The lower the priority value, the earlier it will be installed. If two modes are installed
using the same priority value, the first one will be installed earlier.
value
- The Priority to set.getPriority()
public boolean stop()
IInputMode
This should stop the current edit, if one is in progress and possibly commit all of the changes. If stopping is not
possible, this method can return false
stop
in interface IInputMode
true
if and only if the editing has been stopped or there was no edit in progressIInputMode.cancel()
public void uninstall(IInputModeContext context)
This code should clean up all changes made to the canvas in the IInputMode.install(IInputModeContext, ConcurrencyController)
method. After a mode has been uninstalled it can be installed again into the same or another canvas.
Overriding implementations should call the base implementation after their own code.
uninstall
in interface IInputMode
context
- The context to deregister from. This is the same instance that had been passed to IInputMode.install(IInputModeContext, ConcurrencyController)
during installation.