MayaFlux 1.0.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)
});
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
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 125 of file InputEvents.cpp.

129{
130 auto& promise = co_await GetEventPromise {};
131 auto& source = window->get_event_source();
132
134 filter.event_type = Core::WindowEventType::MOUSE_BUTTON_PRESSED;
135 filter.button = button;
136
137 while (true) {
138 if (promise.should_terminate) {
139 break;
140 }
141
142 co_await WindowEventAwaiter(source, filter);
143
144 auto [x, y] = source.get_mouse_position();
145 callback(x, y);
146 }
147}
PickCallback callback
Definition Picker.cpp:22
Event-domain promise accessor with optional NetworkSource ownership transfer.
std::optional< Core::WindowEventType > event_type
std::optional< IO::MouseButtons > button
Filter criteria for window input events.

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

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: