TextEdit: left/right arrows move cursor to start/end of selection

Closes https://github.com/emilk/egui/issues/611
This commit is contained in:
Emil Ernerfeldt 2021-09-05 11:11:31 +02:00
parent 2382425198
commit f9afdfa143

View file

@ -1135,6 +1135,15 @@ fn on_key_press<S: TextBuffer>(
Some(CCursorPair::one(ccursor))
}
Key::ArrowLeft | Key::ArrowRight if modifiers.is_none() && !cursorp.is_empty() => {
if key == Key::ArrowLeft {
*cursorp = CursorPair::one(cursorp.sorted()[0]);
} else {
*cursorp = CursorPair::one(cursorp.sorted()[1]);
}
None
}
Key::ArrowLeft | Key::ArrowRight | Key::ArrowUp | Key::ArrowDown | Key::Home | Key::End => {
move_single_cursor(&mut cursorp.primary, galley, key, modifiers);
if !modifiers.shift {