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

◆ mouse_moved()

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

Creates an Event coroutine that triggers on mouse movement.

Parameters
windowWindow to listen to
callbackFunction to call on mouse move
Returns
Event coroutine that can be added to EventManager

Example:

auto task = mouse_moved(window,
[](double x, double y) {
// Handle mouse move at (x, y)
});
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
Vruta::Event mouse_moved(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse movement.

Definition at line 173 of file InputEvents.cpp.

176{
177 auto& promise = co_await GetEventPromise {};
178 auto& source = window->get_event_source();
179
181 filter.event_type = Core::WindowEventType::MOUSE_MOTION;
182
183 while (true) {
184 if (promise.should_terminate) {
185 break;
186 }
187
188 auto event = co_await WindowEventAwaiter(source, filter);
189
190 if (auto* pos_data = std::get_if<Core::WindowEvent::MousePosData>(&event.data)) {
191 callback(pos_data->x, pos_data->y);
192 }
193 }
194}
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::Core::MOUSE_MOTION, and window.

Referenced by MayaFlux::on_mouse_move(), and MayaFlux::Portal::Forma::Context::register_handlers().

+ Here is the caller graph for this function: