Add mouse scroll for iced example

This commit is contained in:
Jeremy Soller 2022-10-18 13:27:58 -06:00
parent 2f6a9d33d1
commit 38a4f7a09a
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE

View file

@ -7,6 +7,7 @@ use cosmic::iced_native::{
}, },
keyboard::{Event as KeyEvent, KeyCode}, keyboard::{Event as KeyEvent, KeyCode},
layout::{self, Layout}, layout::{self, Layout},
mouse::{Event as MouseEvent, ScrollDelta},
renderer, renderer,
widget::{self, Widget}, widget::{self, Widget},
}; };
@ -258,6 +259,16 @@ where
}, },
_ => Status::Ignored, _ => Status::Ignored,
}, },
Event::Mouse(mouse_event) => match mouse_event {
MouseEvent::WheelScrolled { delta } => match delta {
ScrollDelta::Lines { x, y } => {
buffer.action(TextAction::Scroll(-y as i32 * 6));
Status::Captured
},
_ => Status::Ignored,
}
_ => Status::Ignored,
},
_ => Status::Ignored, _ => Status::Ignored,
} }
} }