MayaFlux 1.0.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 105 of file Context.cpp.

106{
107 const int key_code = static_cast<int>(key);
108 m_callbacks[id].key_held[key_code] = std::move(fn);
109
110 if (!m_registered_keys[key_code].has_held) {
111 const std::string key_name = std::to_string(key_code);
113 std::make_shared<Vruta::Event>(
115 [this, key]() { handle_key_held(key); })),
116 m_name + "_key_held_" + key_name);
117 m_registered_keys[key_code].has_held = true;
118 }
119}
std::unordered_map< int, KeyHandlerState > m_registered_keys
Definition Context.hpp:353
void handle_key_held(IO::Keys key)
Definition Context.cpp:509
Vruta::EventManager & m_event_manager
Definition Context.hpp:357
std::shared_ptr< Core::Window > m_window
Definition Context.hpp:356
std::unordered_map< uint32_t, ElementCallbacks > m_callbacks
Definition Context.hpp:361
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(), and press_and_hold().

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