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

◆ mouse_dragged()

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

Creates an Event coroutine that triggers on mouse drag with specific button.

Parameters
windowWindow to listen to
buttonMouse button that must be held for drag
callbackFunction to call on mouse drag with current position
Returns
Event coroutine that can be added to EventManager

Example:

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

Definition at line 173 of file InputEvents.cpp.

177{
178 auto& promise = co_await GetEventPromise {};
179 auto& source = window->get_event_source();
180
182 filter.event_type = Core::WindowEventType::MOUSE_MOTION;
183
184 while (true) {
185 if (promise.should_terminate)
186 break;
187
188 auto event = co_await WindowEventAwaiter(source, filter);
189
190 if (!source.is_mouse_pressed(static_cast<int>(button)))
191 continue;
192
193 if (auto* pos = std::get_if<Core::WindowEvent::MousePosData>(&event.data))
194 callback(pos->x, pos->y);
195 }
196}
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::Nexus::Wiring::finalise(), MayaFlux::on_mouse_drag(), and MayaFlux::Portal::Forma::Context::register_handlers().

+ Here is the caller graph for this function: