public abstract class InputHandler
extends java.lang.Object
implements java.awt.event.KeyListener
This class provides all the necessary support code for an input handler, but doesn't actually do any key binding logic. It is up to the implementations of this class to do so.
DefaultInputHandler
Modifier and Type | Class and Description |
---|---|
static interface |
InputHandler.NonRepeatable
If an action implements this interface, it should not be repeated.
|
Modifier and Type | Field and Description |
---|---|
protected int |
repeatCount |
Constructor and Description |
---|
InputHandler() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addDefaultKeyBindings()
Adds the default key bindings to this input handler.
|
abstract InputHandler |
copy()
Returns a copy of this input handler that shares the same key bindings.
|
protected void |
executeAction(java.awt.event.ActionListener listener,
java.lang.Object source,
@Nullable java.lang.String actionCommand)
Executes the specified action, repeating and recording it as necessary.
|
int |
getRepeatCount()
Returns the number of times the next action will be repeated.
|
static @NotNull JEditTextArea |
getTextArea(java.util.EventObject evt)
Returns the text area that fired the specified event.
|
protected boolean |
handleGrabAction(java.awt.event.KeyEvent evt)
If a key is being grabbed, this method should be called with the
appropriate key event.
|
protected boolean |
isRepeatEnabled()
Returns if repetition is enabled.
|
void |
setRepeatCount(int repeatCount)
Sets the number of times the next action will be repeated.
|
void |
setRepeatEnabled(boolean repeat)
Sets the enabled state of repetition.
|
public abstract void addDefaultKeyBindings()
protected boolean isRepeatEnabled()
true
if repeating is enabled, otherwise false
public void setRepeatEnabled(boolean repeat)
repeat
- true
for enabling repetition, false
for
disabling itpublic int getRepeatCount()
public void setRepeatCount(int repeatCount)
repeatCount
- the repeat countpublic abstract InputHandler copy()
protected void executeAction(java.awt.event.ActionListener listener, java.lang.Object source, @Nullable @Nullable java.lang.String actionCommand)
listener
- the action listenersource
- the event sourceactionCommand
- the action command@NotNull public static @NotNull JEditTextArea getTextArea(java.util.EventObject evt)
Error
if evt
does not have a JEditTextArea in
it's source component hierarchy.evt
- the eventevt
protected boolean handleGrabAction(java.awt.event.KeyEvent evt)
evt
- the key event the key should be grabbed of