FloUI.Scrollable.Hotkeys (FloUI v0.1.0-alpha.6) View Source
This module handles key mappings and keypress events for Scenic.Scrollable
components.
Link to this section Summary
Types
The keymap used internally to determine if, and what key is set for a certain movement. TODO support multiple keys for a single movement.
Button state containing information on if a key is currently pressed or released.
Data structure containing information on the pressed state of all available hotkeys.
A keycode represented by a string. The string corresponds to the character as seen on the keyboard, rather than a numeric keycode. Special keys are generally spelled out in lower case characters, such as "enter" or "escape".
The hotkey settings which can be passed in as style when creating a scrollable component. Hotkeys are optional and available for 'up', 'down', 'left' and 'right' scroll movements.
The data structure used as state by this module. It contains information on what keys are mapped to what functionality, and which keys are currently being pressed.
Functions
Obtain the current scroll direction based on the keys currently being pressed as a t:Scenic.Math.vector_2
.
For example, when the 'left' key and the 'up' key are currently being pressed, the vector {-1, 1} describing the corresponding direction will be returned.
Modifies the hotkey state accordingly to the key mappings and the keycode passed. When the passed keycode is set as one of the mapped keys, that key will be flagged as being pressed.
Modifies the hotkey state accordingly to the key mappings and the keycode passed. When the passed keycode is set as one of the mapped keys, that key will be flagged as being released.
Initialize the state this module acts upon, by passing it the t:Scenic.Scrollable.Hotkeys.settings/0
settings map.
When nil is passed as argument, the default settings will be used.
Returns a t:Scenic.Scrollable.Hotkeys.t/0
.
Verify if one or more hotkeys are currently being pressed.
Link to this section Types
Specs
key_map() :: %{ up: :none | {:some, keycode()}, down: :none | {:some, keycode()}, left: :none | {:some, keycode()}, right: :none | {:some, keycode()} }
The keymap used internally to determine if, and what key is set for a certain movement. TODO support multiple keys for a single movement.
Specs
key_pressed_state() :: :released | :pressed
Button state containing information on if a key is currently pressed or released.
Specs
key_pressed_states() :: %{ up: key_pressed_state(), down: key_pressed_state(), left: key_pressed_state(), right: key_pressed_state() }
Data structure containing information on the pressed state of all available hotkeys.
Specs
keycode() :: String.t()
A keycode represented by a string. The string corresponds to the character as seen on the keyboard, rather than a numeric keycode. Special keys are generally spelled out in lower case characters, such as "enter" or "escape".
Specs
settings() :: %{ optional(:up) => keycode(), optional(:down) => keycode(), optional(:left) => keycode(), optional(:right) => keycode() }
The hotkey settings which can be passed in as style when creating a scrollable component. Hotkeys are optional and available for 'up', 'down', 'left' and 'right' scroll movements.
Specs
t() :: %FloUI.Scrollable.Hotkeys{ key_map: key_map(), key_pressed_states: key_pressed_states() }
The data structure used as state by this module. It contains information on what keys are mapped to what functionality, and which keys are currently being pressed.
Link to this section Functions
Specs
direction(t()) :: Scenic.Math.vector_2()
Obtain the current scroll direction based on the keys currently being pressed as a t:Scenic.Math.vector_2
.
For example, when the 'left' key and the 'up' key are currently being pressed, the vector {-1, 1} describing the corresponding direction will be returned.
Specs
Modifies the hotkey state accordingly to the key mappings and the keycode passed. When the passed keycode is set as one of the mapped keys, that key will be flagged as being pressed.
Modifies the hotkey state accordingly to the key mappings and the keycode passed. When the passed keycode is set as one of the mapped keys, that key will be flagged as being released.
Specs
Initialize the state this module acts upon, by passing it the t:Scenic.Scrollable.Hotkeys.settings/0
settings map.
When nil is passed as argument, the default settings will be used.
Returns a t:Scenic.Scrollable.Hotkeys.t/0
.
Specs
Verify if one or more hotkeys are currently being pressed.