InputHandler
, TextAreaInputHandler
public abstract class AbstractInputHandler<E extends JEditAbstractEditAction>
extends java.lang.Object
processKeyEvent(java.awt.event.KeyEvent, int, boolean)
Modifier and Type | Field | Description |
---|---|---|
protected java.util.Hashtable |
bindings |
|
protected java.util.Hashtable |
currentBindings |
|
protected java.awt.event.KeyListener |
keyEventInterceptor |
This listener will receive keyboard events if it is not null.
|
protected E |
lastAction |
|
protected int |
lastActionCount |
|
static java.lang.Object |
PREFIX_STR |
|
protected java.lang.String |
readNextChar |
|
protected static int |
REPEAT_COUNT_THRESHOLD |
|
protected int |
repeatCount |
|
protected boolean |
shortcutOn |
Constructor | Description |
---|---|
AbstractInputHandler() |
Modifier and Type | Method | Description |
---|---|---|
void |
addKeyBinding(java.lang.String keyBinding,
E action) |
Adds a key binding to this input handler.
|
void |
addKeyBinding(java.lang.String keyBinding,
java.lang.Object action) |
Adds a key binding to this input handler.
|
void |
addKeyBinding(java.lang.String keyBinding,
java.lang.String action) |
Adds a key binding to this input handler.
|
java.lang.Object |
getKeyBinding(java.lang.String keyBinding) |
Returns either an edit action, or a hashtable if the specified key
is a prefix.
|
java.awt.event.KeyListener |
getKeyEventInterceptor() |
|
int |
getLastActionCount() |
Returns the number of times the last action was executed.
|
abstract boolean |
handleKey(KeyEventTranslator.Key keyStroke,
boolean dryRun) |
Handles a keystroke.
|
abstract void |
invokeAction(E action) |
|
abstract void |
invokeAction(java.lang.String action) |
|
boolean |
isPrefixActive() |
Returns if a prefix key has been pressed.
|
abstract void |
processKeyEvent(java.awt.event.KeyEvent evt,
int from,
boolean global) |
Process a keyboard event.
|
protected void |
processKeyEventKeyStrokeHandling(java.awt.event.KeyEvent evt,
int from,
java.lang.String mode,
boolean global) |
|
void |
removeAllKeyBindings() |
Removes all key bindings from this input handler.
|
void |
removeKeyBinding(java.lang.String keyBinding) |
Removes a key binding from this input handler.
|
void |
resetLastActionCount() |
Resets the last action count.
|
protected void |
sendShortcutPrefixOff() |
|
void |
setBindings(java.util.Hashtable bindings) |
Replace the set of key bindings.
|
void |
setCurrentBindings(java.util.Hashtable bindings) |
|
void |
setKeyEventInterceptor(java.awt.event.KeyListener keyEventInterceptor) |
Sets the listener that will handle all key events in this
view.
|
static java.lang.String |
toString(java.awt.event.KeyEvent evt) |
Return a String representation of the keyboard event for
debugging purpose.
|
protected int lastActionCount
protected java.awt.event.KeyListener keyEventInterceptor
protected java.lang.String readNextChar
protected int repeatCount
protected E extends JEditAbstractEditAction lastAction
protected static final int REPEAT_COUNT_THRESHOLD
public static java.lang.Object PREFIX_STR
protected boolean shortcutOn
protected java.util.Hashtable bindings
protected java.util.Hashtable currentBindings
public void addKeyBinding(java.lang.String keyBinding, java.lang.String action)
keyBinding
- The key bindingaction
- The actionpublic void addKeyBinding(java.lang.String keyBinding, E action)
keyBinding
- The key bindingaction
- The actionpublic void addKeyBinding(java.lang.String keyBinding, java.lang.Object action)
keyBinding
- The key bindingaction
- The actionpublic void removeKeyBinding(java.lang.String keyBinding)
keyBinding
- The key bindingpublic void removeAllKeyBindings()
@Nullable public java.lang.Object getKeyBinding(@Nonnull java.lang.String keyBinding)
keyBinding
- The key bindingpublic int getLastActionCount()
public void resetLastActionCount()
public java.awt.event.KeyListener getKeyEventInterceptor()
public void setKeyEventInterceptor(java.awt.event.KeyListener keyEventInterceptor)
keyEventInterceptor
- the KeyListener that will receive the eventspublic boolean isPrefixActive()
public void setBindings(java.util.Hashtable bindings)
public void setCurrentBindings(java.util.Hashtable bindings)
public abstract boolean handleKey(KeyEventTranslator.Key keyStroke, boolean dryRun)
keyStroke
- The key stroke.dryRun
- only calculate the return value, do not have any other effectpublic abstract void processKeyEvent(java.awt.event.KeyEvent evt, int from, boolean global)
evt
- the keyboard eventfrom
- the source, it can be View.VIEW
,
View.ACTION_BAR
or View.TEXT_AREA
global
- tell if the event comes from the DefaultKeyboardFocusManager or notprotected void sendShortcutPrefixOff()
public abstract void invokeAction(java.lang.String action)
public abstract void invokeAction(E action)
public static java.lang.String toString(java.awt.event.KeyEvent evt)
evt
- the keyboard eventprotected void processKeyEventKeyStrokeHandling(java.awt.event.KeyEvent evt, int from, java.lang.String mode, boolean global)
evt
- the keyboard eventfrom
- the source, it can be View.VIEW
,
View.ACTION_BAR
or View.TEXT_AREA
mode
- the mode is "press" or "type" and is used for debug onlyglobal
- tell if the event comes from the DefaultKeyboardFocusManager or not