KeyPressDispatcher

class KeyPressDispatcher(name: String?) : HashMap<KeyCharAndCode, () -> Unit>

A manager for a keyTypedInputListener, based on HashMap. Uses KeyCharAndCode as keys to express bindings for both Ascii and function keys.

install and uninstall handle adding the listener to a Stage. Use indexed assignments to react to specific keys, e.g.:

    keyPressDispatcher[Input.Keys.F1] = { showHelp() }
keyPressDispatcher['+'] = { zoomIn() }

Optionally use setCheckpoint and revertToCheckPoint to remember and restore one state.

Parameters

name

Optional name of the container screen or popup for debugging

Constructors

KeyPressDispatcher
Link copied to clipboard
fun KeyPressDispatcher(name: String? = null)

Types

Companion
Link copied to clipboard
object Companion

Functions

afterNodeAccess
Link copied to clipboard
open fun afterNodeAccess(p0: HashMap.Node<KeyCharAndCode, () -> Unit>)
afterNodeInsertion
Link copied to clipboard
open fun afterNodeInsertion(p0: Boolean)
afterNodeRemoval
Link copied to clipboard
open fun afterNodeRemoval(p0: HashMap.Node<KeyCharAndCode, () -> Unit>)
capacity
Link copied to clipboard
fun capacity(): Int
checkInstall
Link copied to clipboard
private fun checkInstall(forceRemove: Boolean = false)

Implements lazy hooking of the listener into the stage.

clear
Link copied to clipboard
open override fun clear()

Removes all of the mappings, including a checkpoint if set.

clone
Link copied to clipboard
open override fun clone(): Any
compute
Link copied to clipboard
open override fun compute(p0: KeyCharAndCode, p1: BiFunction<in KeyCharAndCode, in () -> Unit?, out () -> Unit?>): () -> Unit?
computeIfAbsent
Link copied to clipboard
open override fun computeIfAbsent(p0: KeyCharAndCode, p1: Function<in KeyCharAndCode, out () -> Unit>): () -> Unit
computeIfPresent
Link copied to clipboard
open override fun computeIfPresent(p0: KeyCharAndCode, p1: BiFunction<in KeyCharAndCode, in () -> Unit, out () -> Unit?>): () -> Unit?
contains
Link copied to clipboard
operator fun contains(char: Char): Boolean
operator fun contains(code: Int): Boolean
containsKey
Link copied to clipboard
open override fun containsKey(key: KeyCharAndCode): Boolean
containsValue
Link copied to clipboard
open override fun containsValue(value: () -> Unit): Boolean
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
forEach
Link copied to clipboard
open override fun forEach(p0: BiConsumer<in KeyCharAndCode, in () -> Unit>)
get
Link copied to clipboard
operator fun get(char: Char): () -> Unit?
operator fun get(code: Int): () -> Unit?
open operator override fun get(key: KeyCharAndCode): () -> Unit?
getNode
Link copied to clipboard
fun getNode(p0: Int, p1: Any): HashMap.Node<KeyCharAndCode, () -> Unit>
getOrDefault
Link copied to clipboard
open override fun getOrDefault(key: KeyCharAndCode, defaultValue: () -> Unit): () -> Unit
hashCode
Link copied to clipboard
open override fun hashCode(): Int
install
Link copied to clipboard
fun install(stage: Stage, checkIgnoreKeys: () -> Boolean? = null)

install our EventListener on a stage with optional inhibitor

internalWriteEntries
Link copied to clipboard
open fun internalWriteEntries(p0: ObjectOutputStream)
isEmpty
Link copied to clipboard
open override fun isEmpty(): Boolean
loadFactor
Link copied to clipboard
fun loadFactor(): Float
merge
Link copied to clipboard
open override fun merge(p0: KeyCharAndCode, p1: () -> Unit, p2: BiFunction<in () -> Unit, in () -> Unit, out () -> Unit?>): () -> Unit?
newNode
Link copied to clipboard
open fun newNode(p0: Int, p1: KeyCharAndCode, p2: () -> Unit, p3: HashMap.Node<KeyCharAndCode, () -> Unit>): HashMap.Node<KeyCharAndCode, () -> Unit>
newTreeNode
Link copied to clipboard
open fun newTreeNode(p0: Int, p1: KeyCharAndCode, p2: () -> Unit, p3: HashMap.Node<KeyCharAndCode, () -> Unit>): HashMap.TreeNode<KeyCharAndCode, () -> Unit>
put
Link copied to clipboard
open override fun put(key: KeyCharAndCode, value: () -> Unit): () -> Unit?
putAll
Link copied to clipboard
open override fun putAll(from: Map<out KeyCharAndCode, () -> Unit>)
putIfAbsent
Link copied to clipboard
open override fun putIfAbsent(p0: KeyCharAndCode, p1: () -> Unit): () -> Unit?
putMapEntries
Link copied to clipboard
fun putMapEntries(p0: MutableMap<out KeyCharAndCode, out () -> Unit>, p1: Boolean)
putVal
Link copied to clipboard
fun putVal(p0: Int, p1: KeyCharAndCode, p2: () -> Unit, p3: Boolean, p4: Boolean): () -> Unit
readObject
Link copied to clipboard
private open fun readObject(p0: ObjectInputStream)
reinitialize
Link copied to clipboard
open fun reinitialize()
remove
Link copied to clipboard
open override fun remove(key: KeyCharAndCode): () -> Unit?
fun remove(char: Char): () -> Unit?
fun remove(code: Int): () -> Unit?
open override fun remove(key: KeyCharAndCode, value: () -> Unit): Boolean
removeNode
Link copied to clipboard
fun removeNode(p0: Int, p1: Any, p2: Any, p3: Boolean, p4: Boolean): HashMap.Node<KeyCharAndCode, () -> Unit>
replace
Link copied to clipboard
open override fun replace(p0: KeyCharAndCode, p1: () -> Unit): () -> Unit?
open override fun replace(p0: KeyCharAndCode, p1: () -> Unit, p2: () -> Unit): Boolean
replaceAll
Link copied to clipboard
open override fun replaceAll(p0: BiFunction<in KeyCharAndCode, in () -> Unit, out () -> Unit>)
replacementNode
Link copied to clipboard
open fun replacementNode(p0: HashMap.Node<KeyCharAndCode, () -> Unit>, p1: HashMap.Node<KeyCharAndCode, () -> Unit>): HashMap.Node<KeyCharAndCode, () -> Unit>
replacementTreeNode
Link copied to clipboard
open fun replacementTreeNode(p0: HashMap.Node<KeyCharAndCode, () -> Unit>, p1: HashMap.Node<KeyCharAndCode, () -> Unit>): HashMap.TreeNode<KeyCharAndCode, () -> Unit>
resize
Link copied to clipboard
fun resize(): Array<HashMap.Node<KeyCharAndCode, () -> Unit>>
revertToCheckPoint
Link copied to clipboard
fun revertToCheckPoint()

Revert to a checkpoint: Remove all mappings except those that existed on a previous setCheckpoint call. If no checkpoint has been set, this is equivalent to clear

set
Link copied to clipboard
operator fun set(key: KeyCharAndCode, action: () -> Unit)
operator fun set(char: Char, action: () -> Unit)
operator fun set(code: Int, action: () -> Unit)
setCheckpoint
Link copied to clipboard
fun setCheckpoint()

Set a checkpoint: The current set of keys will not be removed on a subsequent revertToCheckPoint

toString
Link copied to clipboard
open override fun toString(): String
treeifyBin
Link copied to clipboard
fun treeifyBin(p0: Array<HashMap.Node<KeyCharAndCode, () -> Unit>>, p1: Int)
uninstall
Link copied to clipboard
fun uninstall()

uninstall our EventListener from the stage it was installed on.

writeObject
Link copied to clipboard
private open fun writeObject(p0: ObjectOutputStream)

Properties

checkpoint
Link copied to clipboard
private var checkpoint: Set<KeyCharAndCode>
entries
Link copied to clipboard
open override val entries: MutableSet<MutableMap.MutableEntry<KeyCharAndCode, () -> Unit>>
entrySet
Link copied to clipboard
val entrySet: MutableSet<MutableMap.MutableEntry<KeyCharAndCode, () -> Unit>>
installStage
Link copied to clipboard
private var installStage: Stage? = null
isPaused
Link copied to clipboard
var isPaused: Boolean = false

Allows temporarily suspending this KeyPressDispatcher

keys
Link copied to clipboard
open override val keys: MutableSet<KeyCharAndCode>
keySet
Link copied to clipboard
val keySet: MutableSet<KeyCharAndCode>
listener
Link copied to clipboard
private var listener: EventListener? = null
listenerInstalled
Link copied to clipboard
private var listenerInstalled: Boolean = false
loadFactor
Link copied to clipboard
val loadFactor: Float
modCount
Link copied to clipboard
val modCount: Int
name
Link copied to clipboard
val name: String? = null
size
Link copied to clipboard
val size: Int
size
Link copied to clipboard
open override val size: Int
table
Link copied to clipboard
val table: Array<HashMap.Node<KeyCharAndCode, () -> Unit>>
threshold
Link copied to clipboard
val threshold: Int
values
Link copied to clipboard
open override val values: MutableCollection<() -> Unit>
values
Link copied to clipboard
val values: MutableCollection<() -> Unit>

Sources

jvm source
Link copied to clipboard