Control class which enables customization
by allowing creation of custom key mappings and event handlers.
The InputMap serves as a bridge between the Control and its Skin.
The InputMap provides an ordered repository of event handlers,
working together with the input map managed by the skin, which
guarantees the order in which handlers are invoked.
It also stores key mappings with a similar guarantee that the application mappings
always take precedence over mappings created by the skin,
regardless of when the skin was created or replaced.
The class supports the following scenarios:
InputMap utilizes a two-stage lookup.
First, the key event is matched to a FunctionTag which identifies a function provided either by the skin
or the associated behavior (the "default" function), or by the application.
When such a mapping exists, the found function tag is matched to a function registered either by
the application or by the skin.
Additionally, the register(KeyBinding, Runnable) method allows mapping to a function directly,
bypassing the function tag.
This mechanism allows for customizing the key mappings and the underlying functions independently and separately.
| Modifier and Type | Field and Description |
|---|---|
| private final Control | |
| private final EventHandler | |
| private final KeyEventMapper | |
| private final HashMap | map
KeyBinding -> FunctionTag or Runnable FunctionTag -> Runnable EventType -> PHList |
| private static final Object | |
| private SkinInputMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public < the actual event type T extends Event> void | addHandler(EventType<T>
the event type type, EventHandler<T> the event handler handler)Adds an event handler for the specified event type. |
| private Set | |
| public void | |
| private boolean | |
| pack-priv boolean | |
| pack-priv boolean | |
| private <T extends Event> void | |
| public Set | |
| public Set | Returns: the set of KeyBindings, non-nullthe function tag tag)Returns the set of key bindings mapped to the specified function tag. |
| private void | |
| private void | |
| private static void | |
| public void | register(KeyBinding
the key binding k, Runnable the function function)Registers a function for the given key binding. |
| public void | registerFunction(FunctionTag
the function tag tag, Runnable the function function)Adds (or overrides) a user-specified function under the given function tag. |
| public void | registerKey(KeyBinding
the key binding k, FunctionTag the function tag tag)Link a key binding to the specified function tag. |
| public < the event class T extends Event> void | removeHandler(EventType<T>
the event type type, EventHandler<T> the handler to remove handler)Removes the specified handler. |
| private <T extends Event> void | |
| public void | removeKeyBindingsFor(FunctionTag
the function tag tag)Removes all the key bindings mapped to the specified function tag, either by the application or by the skin. |
| public void | |
| private Object | |
| public void | restoreDefaultFunction(FunctionTag
the function tag tag)Restores the specified function tag to the value set by the skin, if any. |
| public void | restoreDefaultKeyBinding(KeyBinding
the key binding k)Restores the specified key binding to the value set by the skin, if any. |
| private void | setSkinInputMap(SkinInputMap
the skin input map m)Sets the skin input map, adding necessary event handlers to the control instance when required. |
| control | back to summary |
|---|---|
| private final Control control | |
| eventHandler | back to summary |
|---|---|
| private final EventHandler<Event> eventHandler | |
| kmapper | back to summary |
|---|---|
| private final KeyEventMapper kmapper | |
| map | back to summary |
|---|---|
private final HashMap<Object, Object> mapKeyBinding -> FunctionTag or Runnable FunctionTag -> Runnable EventType -> PHList | |
| NULL | back to summary |
|---|---|
| private static final Object NULL | |
| skinInputMap | back to summary |
|---|---|
| private SkinInputMap skinInputMap | |
| InputMap | back to summary |
|---|---|
| public InputMap(Control control) The constructor.
| |
| addHandler | back to summary |
|---|---|
| public <T extends Event> void addHandler(EventType<T> type, EventHandler<T> handler) Adds an event handler for the specified event type. Event handlers added with this method will always be called before any handlers registered by the skin.
| |
| collectKeyBindings | back to summary |
|---|---|
| private Set | |
| disableKeyBinding | back to summary |
|---|---|
| public void disableKeyBinding(KeyBinding k) Disables the specified key binding.
Calling this method will disable any mappings made with
| |
| execute | back to summary |
|---|---|
| private boolean execute(Object source, KeyBinding k) | |
| execute | back to summary |
|---|---|
| pack-priv boolean execute(Object source, FunctionTag tag) | |
| executeDefault | back to summary |
|---|---|
| pack-priv boolean executeDefault(Object source, FunctionTag tag) | |
| extendHandler | back to summary |
|---|---|
| private <T extends Event> void extendHandler(EventType<T> t, EventHandler<T> handler, EventHandlerPriority pri) | |
| getKeyBindings | back to summary |
|---|---|
| public Set Collects all mapped key bindings.
| |
| getKeyBindingsFor | back to summary |
|---|---|
| public Set Returns the set of key bindings mapped to the specified function tag.
| |
| handleEvent | back to summary |
|---|---|
| private void handleEvent(Event ev) | |
| handleKeyBindingEvent | back to summary |
|---|---|
| private void handleKeyBindingEvent(Event ev) | |
| initAccessor | back to summary |
|---|---|
| private static void initAccessor() | |
| register | back to summary |
|---|---|
| public void register(KeyBinding k, Runnable function) Registers a function for the given key binding. This mapping will take precedence over the default mapping set by the skin.
| |
| registerFunction | back to summary |
|---|---|
| public void registerFunction(FunctionTag tag, Runnable function) Adds (or overrides) a user-specified function under the given function tag. This function will take precedence over any default function set by the skin.
| |
| registerKey | back to summary |
|---|---|
| public void registerKey(KeyBinding k, FunctionTag tag) Link a key binding to the specified function tag. When the key binding matches the input event, the function is executed, the event is consumed, and the process of dispatching is stopped. This method will take precedence over any default function set by the skin.
| |
| removeHandler | back to summary |
|---|---|
| public <T extends Event> void removeHandler(EventType<T> type, EventHandler<T> handler) Removes the specified handler.
| |
| removeHandler | back to summary |
|---|---|
| private <T extends Event> void removeHandler(EventType<T> type, EventHandlerPriority pri) | |
| removeKeyBindingsFor | back to summary |
|---|---|
| public void removeKeyBindingsFor(FunctionTag tag) Removes all the key bindings mapped to the specified function tag, either by the application or by the skin. This is an irreversible operation.
| |
| resetKeyBindings | back to summary |
|---|---|
| public void resetKeyBindings() Reverts all the key bindings set by user. This method restores key bindings set by the skin which were overwritten by the user. | |
| resolve | back to summary |
|---|---|
| private Object resolve(KeyBinding k) | |
| restoreDefaultFunction | back to summary |
|---|---|
| public void restoreDefaultFunction(FunctionTag tag) Restores the specified function tag to the value set by the skin, if any.
| |
| restoreDefaultKeyBinding | back to summary |
|---|---|
| public void restoreDefaultKeyBinding(KeyBinding k) Restores the specified key binding to the value set by the skin, if any.
| |
| setSkinInputMap | back to summary |
|---|---|
| private void setSkinInputMap(SkinInputMap m) Sets the skin input map, adding necessary event handlers to the control instance when required.
This method must be called by the skin only from its
This method removes all the mappings from the previous skin input map, if any.
| |