Scenic Scrollable v0.1.0 Scenic.Scrollable.Hotkeys 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 Scenic.Scrollable.Hotkeys.settings/0
settings map.
When nil is passed as argument, the default settings will be used.
Returns a Scenic.Scrollable.Hotkeys.t/0
Verify if one or more hotkeys are currently being pressed
Link to this section Types
key_map() View Source
The keymap used internally to determine if, and what key is set for a certain movement. TODO support multiple keys for a single movement.
key_pressed_state()
View Source
key_pressed_state() :: :released | :pressed
key_pressed_state() :: :released | :pressed
Button state containing information on if a key is currently pressed or released.
key_pressed_states()
View Source
key_pressed_states() :: %{
up: key_pressed_state(),
down: key_pressed_state(),
left: key_pressed_state(),
right: key_pressed_state()
}
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.
keycode()
View Source
keycode() :: String.t()
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".
settings() View Source
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.
t()
View Source
t() :: %Scenic.Scrollable.Hotkeys{
key_map: key_map(),
key_pressed_states: key_pressed_states()
}
t() :: %Scenic.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
direction(map)
View Source
direction(t()) :: Scenic.Math.vector_2()
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.
handle_key_press(state, key) View Source
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.
handle_key_release(state, key) View Source
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.
init(settings) View Source
Initialize the state this module acts upon, by passing it the Scenic.Scrollable.Hotkeys.settings/0
settings map.
When nil is passed as argument, the default settings will be used.
Returns a Scenic.Scrollable.Hotkeys.t/0
.
is_any_key_pressed?(map) View Source
Verify if one or more hotkeys are currently being pressed.