Implement Scroll action in text::editor
This commit is contained in:
parent
36e867de69
commit
4e757a26d0
3 changed files with 19 additions and 0 deletions
|
|
@ -52,6 +52,7 @@ pub enum Action {
|
||||||
Edit(Edit),
|
Edit(Edit),
|
||||||
Click(Point),
|
Click(Point),
|
||||||
Drag(Point),
|
Drag(Point),
|
||||||
|
Scroll { lines: i32 },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Action {
|
impl Action {
|
||||||
|
|
|
||||||
|
|
@ -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));
|
self.0 = Some(Arc::new(internal));
|
||||||
|
|
|
||||||
|
|
@ -521,6 +521,18 @@ impl Update {
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => 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,
|
_ => None,
|
||||||
},
|
},
|
||||||
Event::Keyboard(event) => match event {
|
Event::Keyboard(event) => match event {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue