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

◆ mouse_scrolled()

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

Creates an Event coroutine that triggers on mouse scroll.

Parameters
windowWindow to listen to
callbackFunction to call on scroll with ScrollData
Returns
Event coroutine that can be added to EventManager

Example:

auto task = mouse_scrolled(window,
[](double xoffset, double yoffset) {
// Handle mouse scroll with offsets
});
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
Vruta::Event mouse_scrolled(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse scroll.

Definition at line 221 of file InputEvents.cpp.

224{
225 auto& promise = co_await GetEventPromise {};
226 auto& source = window->get_event_source();
227
229 filter.event_type = Core::WindowEventType::MOUSE_SCROLLED;
230
231 while (true) {
232 if (promise.should_terminate) {
233 break;
234 }
235
236 auto event = co_await WindowEventAwaiter(source, filter);
237
238 if (auto* scroll_data = std::get_if<Core::WindowEvent::ScrollData>(&event.data)) {
239 callback(scroll_data->x_offset, scroll_data->y_offset);
240 }
241 }
242}
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_SCROLLED, and window.

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

+ Here is the caller graph for this function: