MayaFlux 0.2.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)
});
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 125 of file InputEvents.cpp.

128{
129 auto& promise = co_await GetEventPromise {};
130 auto& source = window->get_event_source();
131
132 Vruta::EventFilter filter;
133 filter.event_type = Core::WindowEventType::MOUSE_MOTION;
134
135 while (true) {
136 if (promise.should_terminate) {
137 break;
138 }
139
140 auto event = co_await EventAwaiter(source, filter);
141
142 if (auto* pos_data = std::get_if<Core::WindowEvent::MousePosData>(&event.data)) {
143 callback(pos_data->x, pos_data->y);
144 }
145 }
146}
Templated awaitable for accessing a coroutine's promise object.
std::optional< Core::WindowEventType > event_type
Filter criteria for window events.

References MayaFlux::Vruta::EventFilter::event_type, and MayaFlux::Core::MOUSE_MOTION.

Referenced by MayaFlux::on_mouse_move().

+ Here is the caller graph for this function: