MayaFlux 0.4.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 150 of file InputEvents.cpp.

153{
154 auto& promise = co_await GetEventPromise {};
155 auto& source = window->get_event_source();
156
158 filter.event_type = Core::WindowEventType::MOUSE_MOTION;
159
160 while (true) {
161 if (promise.should_terminate) {
162 break;
163 }
164
165 auto event = co_await WindowEventAwaiter(source, filter);
166
167 if (auto* pos_data = std::get_if<Core::WindowEvent::MousePosData>(&event.data)) {
168 callback(pos_data->x, pos_data->y);
169 }
170 }
171}
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, and MayaFlux::Core::MOUSE_MOTION.

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

+ Here is the caller graph for this function: