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

◆ key_pressed()

MAYAFLUX_API Vruta::Event MayaFlux::Kriya::key_pressed ( std::shared_ptr< Core::Window >  window,
IO::Keys  key,
std::function< void()>  callback 
)

Creates an Event coroutine that triggers on specific key press.

Parameters
windowWindow to listen to
keyThe key to wait for
callbackFunction to call on key press
Returns
Event coroutine that can be added to EventManager

Example:

[]() {
// Handle Escape key press
});
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
void on_key_pressed(const std::shared_ptr< Core::Window > &window, IO::Keys key, std::function< void()> callback, std::string name)
Schedule a key press handler.
Definition Chronie.cpp:147

Definition at line 10 of file InputEvents.cpp.

14{
15 auto& promise = co_await GetEventPromise {};
16 auto& source = window->get_event_source();
17
19 filter.event_type = Core::WindowEventType::KEY_PRESSED;
20 filter.key_code = key;
21
22 while (true) {
23 if (promise.should_terminate) {
24 break;
25 }
26
27 co_await WindowEventAwaiter(source, filter);
28 callback();
29 }
30}
PickCallback callback
Definition Picker.cpp:22
Event-domain promise accessor with optional NetworkSource ownership transfer.
std::optional< Core::WindowEventType > event_type
Filter criteria for window input events.

References callback, MayaFlux::Vruta::WindowEventFilter::event_type, MayaFlux::Vruta::WindowEventFilter::key_code, MayaFlux::Core::KEY_PRESSED, and window.

Referenced by MayaFlux::Nexus::Wiring::finalise(), MayaFlux::on_key_pressed(), and MayaFlux::Portal::Forma::Context::on_press().

+ Here is the caller graph for this function: