summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/text/editor.rs1
-rw-r--r--graphics/src/text/editor.rs6
-rw-r--r--widget/src/text_editor.rs12
3 files changed, 19 insertions, 0 deletions
diff --git a/core/src/text/editor.rs b/core/src/text/editor.rs
index 13bafc3d..e9d66ce9 100644
--- a/core/src/text/editor.rs
+++ b/core/src/text/editor.rs
@@ -52,6 +52,7 @@ pub enum Action {
Edit(Edit),
Click(Point),
Drag(Point),
+ Scroll { lines: i32 },
}
impl Action {
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs
index dfb91f34..a05312dc 100644
--- a/graphics/src/text/editor.rs
+++ b/graphics/src/text/editor.rs
@@ -446,6 +446,12 @@ impl editor::Editor for Editor {
}
}
}
+ Action::Scroll { lines } => {
+ editor.action(
+ font_system.raw(),
+ cosmic_text::Action::Scroll { lines },
+ );
+ }
}
self.0 = Some(Arc::new(internal));
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index 970ec031..ad12a076 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -521,6 +521,18 @@ impl Update {
}
_ => None,
},
+ mouse::Event::WheelScrolled { delta } => {
+ action(Action::Scroll {
+ lines: match delta {
+ mouse::ScrollDelta::Lines { y, .. } => {
+ -y as i32 * 4
+ }
+ mouse::ScrollDelta::Pixels { y, .. } => {
+ -y.signum() as i32
+ }
+ },
+ })
+ }
_ => None,
},
Event::Keyboard(event) => match event {