public class IlvStartEditTextSelectionAccelerator extends IlvAccelerator
IlvStartEditTextSelectionAccelerator
is an accelerator that
allows the user to start editing the first currently selected text object.
This works only for text objects that use IlvTextSelection
as their selection object, such as IlvText
or IlvLabel
.
The select interactor must also be installed.
The accelerator should be assigned to a key released event, since otherwise
the key to start editing the text object will also be interpreted as the
first character of the edited label.
The following code example shows how to use
IlvStartEditTextSelectionAccelerator
in a simple Java
application:
// Install the select interactor on the view. // Use this interactor to select graphic objects with the mouse. You can then // edit the graphic objects using the start edit text selection accelerator. IlvSelectInteractor inter = new IlvSelectInteractor(); inter.setOpaqueMove(true); mgrview.setInteractor(inter); // Install the start edit text selection accelerator. manager.addAccelerator( new IlvStartEditTextSelectionAccelerator(KeyEvent.KEY_RELEASED, KeyEvent.VK_L, InputEvent.CTRL_MASK, true));
All input events are handled by means of interactors or accelerators. Accelerators,
such as IlvStartEditTextSelectionAccelerator
, are subclasses of
IlvAccelerator
. Each accelerator listens for a specific key event
in the manager. For information on handling events in a manager, see
Handling Events.
The following code examples show how to handle user events:
Constructor and Description |
---|
IlvStartEditTextSelectionAccelerator(int type,
int keyCode,
char keyChar,
int modifiers,
boolean consumeEvents)
Creates an
IlvStartEditTextSelectionAccelerator . |
IlvStartEditTextSelectionAccelerator(int type,
int keyCode,
int modifiers)
Creates an
IlvStartEditTextSelectionAccelerator . |
IlvStartEditTextSelectionAccelerator(int type,
int keyCode,
int modifiers,
boolean consumeEvents)
Creates an
IlvStartEditTextSelectionAccelerator . |
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowsEditText(IlvGraphic obj)
Checks if editing text of the specified object is allowed.
|
protected boolean |
handleEvent(IlvManagerView v)
Processes the event.
|
CtrlChar, getEventType, getKeyChar, getKeyCode, getModifier, isConsumeEvents, setConsumeEvents
public IlvStartEditTextSelectionAccelerator(int type, int keyCode, char keyChar, int modifiers, boolean consumeEvents)
IlvStartEditTextSelectionAccelerator
.
You can specify the associated key either by a key code or by a key
character. Key codes are useful for function keys while
key characters are more useful for regular characters
'a'...'z','A'...'Z','0'...'9','+','-', etc.
which, depending on the keyboard layout may produce different key codes.
For instance, on a US keyboard, the character '+' has the same key code
as the character '=', while on a German keyboard, the character '+' has
the same key code as the character '*', hence specifying the '+'
character by key code instead of key character might be not suitable.
To indicate that only the key code should be checked, pass
KeyEvent.CHAR_UNDEFINED
as key character.
To indicate that only the key character should be checked, pass
KeyEvent.VK_UNDEFINED
as key code.type
- The type of the AWT event.keyCode
- The code associated with the key,
or KeyEvent.VK_UNDEFINED
.keyChar
- The character associated with the key,
or KeyEvent.CHAR_UNDEFINED
.modifiers
- The modifiers of the key.consumeEvents
- If true
, the accelerator handles and
consumes the event, except when the consume flag of the event
is already set to true
. If false
, the
accelerator ignores the event's consume flag, and handles all
events without changing the consume flag.public IlvStartEditTextSelectionAccelerator(int type, int keyCode, int modifiers, boolean consumeEvents)
IlvStartEditTextSelectionAccelerator
.type
- The type of the AWT event.keyCode
- The code associated with the key.modifiers
- The modifiers of the key.consumeEvents
- If true
, the accelerator handles and consumes
the event, except when the consume flag of the event is already set to
true
.
If false
, the accelerator ignores the event's consume flag,
and handles all events without changing the consume flag.public IlvStartEditTextSelectionAccelerator(int type, int keyCode, int modifiers)
IlvStartEditTextSelectionAccelerator
.type
- The type of the AWT event.keyCode
- The code associated with the key.modifiers
- The modifiers of the key.protected boolean allowsEditText(IlvGraphic obj)
obj
- The object to be tested.protected boolean handleEvent(IlvManagerView v)
handleEvent
in class IlvAccelerator
v
- The manager view.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.