MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ on_held()

void MayaFlux::Portal::Forma::Context::on_held ( uint32_t  id,
IO::Keys  key,
KeyFn  fn 
)

Called repeatedly while a key is held and the element has focus.

Fires on initial press and continues on each repeat tick until the key is released. Useful for continuous adjustments (arrow key nudging, value increments) without requiring the user to repeatedly press.

Parameters
idElement id to bind to.
keyThe key to listen for.
fnCallback receiving element id, fired on press and each repeat.

Definition at line 100 of file Context.cpp.

101{
102 const int key_code = static_cast<int>(key);
103 m_callbacks[id].key_held[key_code] = std::move(fn);
104
105 if (!m_registered_keys[key_code].has_held) {
106 const std::string key_name = std::to_string(key_code);
108 std::make_shared<Vruta::Event>(
110 [this, key]() { handle_key_held(key); })),
111 m_name + "_key_held_" + key_name);
112 m_registered_keys[key_code].has_held = true;
113 }
114}
std::unordered_map< int, KeyHandlerState > m_registered_keys
Definition Context.hpp:244
void handle_key_held(IO::Keys key)
Definition Context.cpp:407
Vruta::EventManager & m_event_manager
Definition Context.hpp:248
std::shared_ptr< Core::Window > m_window
Definition Context.hpp:247
std::unordered_map< uint32_t, ElementCallbacks > m_callbacks
Definition Context.hpp:252
void add_event(const std::shared_ptr< Event > &event, const std::string &name="")
Add a event to the manager.
Vruta::Event key_held(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on key press and repeats while held.

References MayaFlux::Vruta::EventManager::add_event(), handle_key_held(), MayaFlux::Kriya::key_held(), m_callbacks, m_event_manager, m_name, m_registered_keys, and m_window.

Referenced by key_step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: