MayaFlux 0.4.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:

auto task = on_key_pressed(window, IO::Keys::Escape,
[]() {
// Handle Escape key press
});
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:133

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}
Event-domain promise accessor with optional NetworkSource ownership transfer.
std::optional< Core::WindowEventType > event_type
Filter criteria for GLFW window input events.

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

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: