summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-06-17 03:37:00 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-06-17 03:37:00 +0200
commit6c1027af8d54ad21e282337b53097eb196d62c00 (patch)
treea25ed59cfe5a3197a88b787a4bc4d16af857e645
parente9141e7abff3ea59e8bc5d8e2e386d564180e0ae (diff)
downloadiced-6c1027af8d54ad21e282337b53097eb196d62c00.tar.gz
iced-6c1027af8d54ad21e282337b53097eb196d62c00.tar.bz2
iced-6c1027af8d54ad21e282337b53097eb196d62c00.zip
Fix `text_editor` always capturing scroll events
-rw-r--r--graphics/src/text/editor.rs12
-rw-r--r--widget/src/text_editor.rs6
2 files changed, 10 insertions, 8 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs
index 4b8f0f2a..c488a51c 100644
--- a/graphics/src/text/editor.rs
+++ b/graphics/src/text/editor.rs
@@ -456,14 +456,10 @@ impl editor::Editor for Editor {
}
}
Action::Scroll { lines } => {
- let (_, height) = editor.buffer().size();
-
- if height < i32::MAX as f32 {
- editor.action(
- font_system.raw(),
- cosmic_text::Action::Scroll { lines },
- );
- }
+ editor.action(
+ font_system.raw(),
+ cosmic_text::Action::Scroll { lines },
+ );
}
}
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index 41b058af..fc2ade43 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -466,6 +466,12 @@ where
shell.publish(on_edit(action));
}
Update::Scroll(lines) => {
+ let bounds = self.content.0.borrow().editor.bounds();
+
+ if bounds.height >= i32::MAX as f32 {
+ return event::Status::Ignored;
+ }
+
let lines = lines + state.partial_scroll;
state.partial_scroll = lines.fract();