git.lucas.co / cce-text-editor
text editor
git clone https://git.lucas.co/cce-text-editor.git

commit577d20723306f3e3e4ed6dbbded4aa0f1d7355a8
parent2d1e9e6acb
authorLucas Galante <[email protected]>
date2026-09-04 09:57
fix: forward the plain wheel to the editor — it never reached the TextBox

`handle_mouse_wheel` only handled ctrl+wheel font-size zoom; a plain wheel
over the document was dropped, since nothing built a `MouseWheel` event
for the editor root. The non-ctrl branch now routes one through
`ui_context.propagate_event` to the TextBox, which owns the document
scroll (and, since cce-ui@0f84843, its glide and coast — its tick runs
through the runner's `ui_context_mut().tick(dt)`).

Co-Authored-By: Claude Fable 5.1 <[email protected]>

 src/main.rs | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/main.rs b/src/main.rs
index 3726e2c..d53d37d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -514,7 +514,7 @@ impl Application for TextEditorApp {
         msg_out
     }
 
-    fn handle_mouse_wheel(&mut self, delta: &MouseScrollDelta, _pos: LogicalPosition, needs_rebuild: &mut bool) {
+    fn handle_mouse_wheel(&mut self, delta: &MouseScrollDelta, pos: LogicalPosition, needs_rebuild: &mut bool) {
         if self.ctrl_pressed {
             match delta {
                 MouseScrollDelta::LineDelta(_, y) => {
@@ -536,6 +536,19 @@ impl Application for TextEditorApp {
                     self.needs_rebuild = true;
                 }
             }
+        } else {
+            // Plain wheel: routed to the editor, whose TextBox owns the
+            // document scroll (glide and coast included — its tick runs
+            // through the runner's ui_context tick). Nothing forwarded it
+            // before, so the wheel over the document was dead.
+            let px = pos.x as f32;
+            let py = pos.y as f32;
+            let ev = cce_ui::widget::Event::MouseWheel { delta: *delta, x: px, y: py, local_x: px, local_y: py };
+            let editor = self.editor.id();
+            if self.ui_context.propagate_event(&ev, editor) {
+                *needs_rebuild = true;
+                self.needs_rebuild = true;
+            }
         }
     }