Merge pull request #2862 from andymandias/text_input-command_shortcuts
⌘ + Backspace and ⌘ + Delete macOS Shortcuts in `text_input`
This commit is contained in:
commit
190b9f60b4
1 changed files with 39 additions and 62 deletions
|
|
@ -1026,14 +1026,15 @@ where
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if modifiers.jump()
|
if state.cursor.selection(&self.value).is_none() {
|
||||||
&& state.cursor.selection(&self.value).is_none()
|
if (self.is_secure && modifiers.jump())
|
||||||
{
|
|| modifiers.macos_command()
|
||||||
if self.is_secure {
|
{
|
||||||
let cursor_pos =
|
state.cursor.select_range(
|
||||||
state.cursor.end(&self.value);
|
state.cursor.start(&self.value),
|
||||||
state.cursor.select_range(0, cursor_pos);
|
0,
|
||||||
} else {
|
);
|
||||||
|
} else if modifiers.jump() {
|
||||||
state
|
state
|
||||||
.cursor
|
.cursor
|
||||||
.select_left_by_words(&self.value);
|
.select_left_by_words(&self.value);
|
||||||
|
|
@ -1056,17 +1057,15 @@ where
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if modifiers.jump()
|
if state.cursor.selection(&self.value).is_none() {
|
||||||
&& state.cursor.selection(&self.value).is_none()
|
if (self.is_secure && modifiers.jump())
|
||||||
{
|
|| modifiers.macos_command()
|
||||||
if self.is_secure {
|
{
|
||||||
let cursor_pos =
|
|
||||||
state.cursor.end(&self.value);
|
|
||||||
state.cursor.select_range(
|
state.cursor.select_range(
|
||||||
cursor_pos,
|
state.cursor.start(&self.value),
|
||||||
self.value.len(),
|
self.value.len(),
|
||||||
);
|
);
|
||||||
} else {
|
} else if modifiers.jump() {
|
||||||
state
|
state
|
||||||
.cursor
|
.cursor
|
||||||
.select_right_by_words(&self.value);
|
.select_right_by_words(&self.value);
|
||||||
|
|
@ -1124,54 +1123,21 @@ where
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
keyboard::Key::Named(key::Named::ArrowLeft)
|
|
||||||
if modifiers.macos_command() =>
|
|
||||||
{
|
|
||||||
let cursor_before = state.cursor;
|
|
||||||
|
|
||||||
if modifiers.shift() {
|
|
||||||
state.cursor.select_range(
|
|
||||||
state.cursor.start(&self.value),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
state.cursor.move_to(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if cursor_before != state.cursor {
|
|
||||||
focus.updated_at = Instant::now();
|
|
||||||
|
|
||||||
shell.request_redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
shell.capture_event();
|
|
||||||
}
|
|
||||||
keyboard::Key::Named(key::Named::ArrowRight)
|
|
||||||
if modifiers.macos_command() =>
|
|
||||||
{
|
|
||||||
let cursor_before = state.cursor;
|
|
||||||
|
|
||||||
if modifiers.shift() {
|
|
||||||
state.cursor.select_range(
|
|
||||||
state.cursor.start(&self.value),
|
|
||||||
self.value.len(),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
state.cursor.move_to(self.value.len());
|
|
||||||
}
|
|
||||||
|
|
||||||
if cursor_before != state.cursor {
|
|
||||||
focus.updated_at = Instant::now();
|
|
||||||
|
|
||||||
shell.request_redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
shell.capture_event();
|
|
||||||
}
|
|
||||||
keyboard::Key::Named(key::Named::ArrowLeft) => {
|
keyboard::Key::Named(key::Named::ArrowLeft) => {
|
||||||
let cursor_before = state.cursor;
|
let cursor_before = state.cursor;
|
||||||
|
|
||||||
if modifiers.jump() && !self.is_secure {
|
if (self.is_secure && modifiers.jump())
|
||||||
|
|| modifiers.macos_command()
|
||||||
|
{
|
||||||
|
if modifiers.shift() {
|
||||||
|
state.cursor.select_range(
|
||||||
|
state.cursor.start(&self.value),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
state.cursor.move_to(0);
|
||||||
|
}
|
||||||
|
} else if modifiers.jump() {
|
||||||
if modifiers.shift() {
|
if modifiers.shift() {
|
||||||
state
|
state
|
||||||
.cursor
|
.cursor
|
||||||
|
|
@ -1198,7 +1164,18 @@ where
|
||||||
keyboard::Key::Named(key::Named::ArrowRight) => {
|
keyboard::Key::Named(key::Named::ArrowRight) => {
|
||||||
let cursor_before = state.cursor;
|
let cursor_before = state.cursor;
|
||||||
|
|
||||||
if modifiers.jump() && !self.is_secure {
|
if (self.is_secure && modifiers.jump())
|
||||||
|
|| modifiers.macos_command()
|
||||||
|
{
|
||||||
|
if modifiers.shift() {
|
||||||
|
state.cursor.select_range(
|
||||||
|
state.cursor.start(&self.value),
|
||||||
|
self.value.len(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
state.cursor.move_to(self.value.len());
|
||||||
|
}
|
||||||
|
} else if modifiers.jump() {
|
||||||
if modifiers.shift() {
|
if modifiers.shift() {
|
||||||
state
|
state
|
||||||
.cursor
|
.cursor
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue