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

200{
201 auto& promise = co_await GetEventPromise {};
202 auto& source = window->get_event_source();
203
205 filter.event_type = Core::WindowEventType::MOUSE_MOTION;
206
207 while (true) {
208 if (promise.should_terminate)
209 break;
210
211 auto event = co_await WindowEventAwaiter(source, filter);
212
213 if (!source.is_mouse_pressed(static_cast<int>(button)))
214 continue;
215
216 if (auto* pos = std::get_if<Core::WindowEvent::MousePosData>(&event.data))
217 callback(pos->x, pos->y);
218 }
219}
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::Nexus::Wiring::finalise(), and MayaFlux::on_mouse_drag().

+ Here is the caller graph for this function: