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

◆ mouse_pressed()

MAYAFLUX_API Vruta::Event MayaFlux::Kriya::mouse_pressed ( std::shared_ptr< Core::Window window,
IO::MouseButtons  button,
std::function< void(double, double)>  callback 
)

Creates an Event coroutine that triggers on specific mouse button press.

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

Example:

[](double x, double y) {
// Handle left mouse button press at (x, y)
});
Vruta::Event mouse_pressed(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on specific mouse button press.

Definition at line 102 of file InputEvents.cpp.

106{
107 auto& promise = co_await GetEventPromise {};
108 auto& source = window->get_event_source();
109
111 filter.event_type = Core::WindowEventType::MOUSE_BUTTON_PRESSED;
112 filter.button = button;
113
114 while (true) {
115 if (promise.should_terminate) {
116 break;
117 }
118
119 co_await WindowEventAwaiter(source, filter);
120
121 auto [x, y] = source.get_mouse_position();
122 callback(x, y);
123 }
124}
Event-domain promise accessor with optional NetworkSource ownership transfer.
std::optional< Core::WindowEventType > event_type
std::optional< IO::MouseButtons > button
Filter criteria for GLFW window input events.

References MayaFlux::Vruta::WindowEventFilter::button, MayaFlux::Vruta::WindowEventFilter::event_type, and MayaFlux::Core::MOUSE_BUTTON_PRESSED.

Referenced by MayaFlux::Nexus::Wiring::finalise(), MayaFlux::on_mouse_pressed(), and MayaFlux::Portal::Forma::Context::register_handlers().

+ Here is the caller graph for this function: