Only scroll text box when cursor is above it
This commit is contained in:
parent
18f2ca563f
commit
1151c64323
1 changed files with 31 additions and 27 deletions
|
|
@ -531,35 +531,39 @@ where
|
||||||
status = Status::Captured;
|
status = Status::Captured;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Mouse(MouseEvent::WheelScrolled { delta }) => match delta {
|
Event::Mouse(MouseEvent::WheelScrolled { delta }) => {
|
||||||
ScrollDelta::Lines { x, y } => {
|
if let Some(_p) = cursor_position.position_in(layout.bounds()) {
|
||||||
//TODO: this adjustment is just a guess!
|
match delta {
|
||||||
state.scroll_pixels = 0.0;
|
ScrollDelta::Lines { x, y } => {
|
||||||
let lines = (-y * 6.0) as i32;
|
//TODO: this adjustment is just a guess!
|
||||||
if lines != 0 {
|
state.scroll_pixels = 0.0;
|
||||||
editor.action(Action::Scroll { lines });
|
let lines = (-y * 6.0) as i32;
|
||||||
|
if lines != 0 {
|
||||||
|
editor.action(Action::Scroll { lines });
|
||||||
|
}
|
||||||
|
status = Status::Captured;
|
||||||
|
}
|
||||||
|
ScrollDelta::Pixels { x, y } => {
|
||||||
|
//TODO: this adjustment is just a guess!
|
||||||
|
state.scroll_pixels -= y * 6.0;
|
||||||
|
let mut lines = 0;
|
||||||
|
let metrics = editor.buffer().metrics();
|
||||||
|
while state.scroll_pixels <= -metrics.line_height {
|
||||||
|
lines -= 1;
|
||||||
|
state.scroll_pixels += metrics.line_height;
|
||||||
|
}
|
||||||
|
while state.scroll_pixels >= metrics.line_height {
|
||||||
|
lines += 1;
|
||||||
|
state.scroll_pixels -= metrics.line_height;
|
||||||
|
}
|
||||||
|
if lines != 0 {
|
||||||
|
editor.action(Action::Scroll { lines });
|
||||||
|
}
|
||||||
|
status = Status::Captured;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
status = Status::Captured;
|
|
||||||
}
|
}
|
||||||
ScrollDelta::Pixels { x, y } => {
|
}
|
||||||
//TODO: this adjustment is just a guess!
|
|
||||||
state.scroll_pixels -= y * 6.0;
|
|
||||||
let mut lines = 0;
|
|
||||||
let metrics = editor.buffer().metrics();
|
|
||||||
while state.scroll_pixels <= -metrics.line_height {
|
|
||||||
lines -= 1;
|
|
||||||
state.scroll_pixels += metrics.line_height;
|
|
||||||
}
|
|
||||||
while state.scroll_pixels >= metrics.line_height {
|
|
||||||
lines += 1;
|
|
||||||
state.scroll_pixels -= metrics.line_height;
|
|
||||||
}
|
|
||||||
if lines != 0 {
|
|
||||||
editor.action(Action::Scroll { lines });
|
|
||||||
}
|
|
||||||
status = Status::Captured;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue