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

201{
202 auto& promise = co_await GetEventPromise {};
203 auto& source = window->get_event_source();
204
206 filter.event_type = Core::WindowEventType::MOUSE_SCROLLED;
207
208 while (true) {
209 if (promise.should_terminate) {
210 break;
211 }
212
213 auto event = co_await WindowEventAwaiter(source, filter);
214
215 if (auto* scroll_data = std::get_if<Core::WindowEvent::ScrollData>(&event.data)) {
216 callback(scroll_data->x_offset, scroll_data->y_offset);
217 }
218 }
219}
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_SCROLLED.

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

+ Here is the caller graph for this function: