core: Move caret to start or end of selection if shift is not held
Previously pressing left with a selection would set `selection.to = selection.start() - 1`, now it sets it to `selection.to = selection.start()`. The same is true for right/selection.end()
This commit is contained in:
parent
464f2b63a9
commit
208a69d715
|
@ -1447,15 +1447,29 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
|
||||||
let text = edit_text.text_spans.text();
|
let text = edit_text.text_spans.text();
|
||||||
let length = text.len();
|
let length = text.len();
|
||||||
match key_code {
|
match key_code {
|
||||||
ButtonKeyCode::Left if selection.to > 0 => {
|
ButtonKeyCode::Left => {
|
||||||
selection.to = string_utils::prev_char_boundary(text, selection.to);
|
if (context.input.is_key_down(KeyCode::Shift) || selection.is_caret())
|
||||||
if !context.input.is_key_down(KeyCode::Shift) {
|
&& selection.to > 0
|
||||||
|
{
|
||||||
|
selection.to = string_utils::prev_char_boundary(text, selection.to);
|
||||||
|
if !context.input.is_key_down(KeyCode::Shift) {
|
||||||
|
selection.from = selection.to;
|
||||||
|
}
|
||||||
|
} else if !context.input.is_key_down(KeyCode::Shift) {
|
||||||
|
selection.to = selection.start();
|
||||||
selection.from = selection.to;
|
selection.from = selection.to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ButtonKeyCode::Right if selection.to < length => {
|
ButtonKeyCode::Right => {
|
||||||
selection.to = string_utils::next_char_boundary(text, selection.to);
|
if (context.input.is_key_down(KeyCode::Shift) || selection.is_caret())
|
||||||
if !context.input.is_key_down(KeyCode::Shift) {
|
&& selection.to < length
|
||||||
|
{
|
||||||
|
selection.to = string_utils::next_char_boundary(text, selection.to);
|
||||||
|
if !context.input.is_key_down(KeyCode::Shift) {
|
||||||
|
selection.from = selection.to;
|
||||||
|
}
|
||||||
|
} else if !context.input.is_key_down(KeyCode::Shift) {
|
||||||
|
selection.to = selection.end();
|
||||||
selection.from = selection.to;
|
selection.from = selection.to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue