fix(input): handle ctrl shortcuts with caps lock
This commit is contained in:
parent
0c6c85429e
commit
a1b64dde3e
1 changed files with 11 additions and 6 deletions
|
|
@ -1629,22 +1629,27 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
key,
|
key,
|
||||||
text,
|
text,
|
||||||
physical_key,
|
physical_key,
|
||||||
|
modifiers,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
let state = state();
|
let state = state();
|
||||||
|
state.keyboard_modifiers = modifiers;
|
||||||
|
|
||||||
if let Some(focus) = state.is_focused.as_mut().filter(|f| f.focused) {
|
if let Some(focus) = state.is_focused.as_mut().filter(|f| f.focused) {
|
||||||
if state.is_read_only || (!manage_value && on_input.is_none()) {
|
if state.is_read_only || (!manage_value && on_input.is_none()) {
|
||||||
return event::Status::Ignored;
|
return event::Status::Ignored;
|
||||||
};
|
};
|
||||||
|
|
||||||
let modifiers = state.keyboard_modifiers;
|
let modifiers = state.keyboard_modifiers;
|
||||||
focus.updated_at = Instant::now();
|
focus.updated_at = Instant::now();
|
||||||
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
|
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
|
||||||
|
|
||||||
// Check if Ctrl+A/C/V/X was pressed.
|
// Check if Ctrl+A/C/V/X was pressed.
|
||||||
if state.keyboard_modifiers.command() {
|
if state.keyboard_modifiers == keyboard::Modifiers::COMMAND
|
||||||
|
|| state.keyboard_modifiers
|
||||||
|
== keyboard::Modifiers::COMMAND | keyboard::Modifiers::CAPS_LOCK
|
||||||
|
{
|
||||||
match key.as_ref() {
|
match key.as_ref() {
|
||||||
keyboard::Key::Character("c") => {
|
keyboard::Key::Character("c") | keyboard::Key::Character("C") => {
|
||||||
if !is_secure {
|
if !is_secure {
|
||||||
if let Some((start, end)) = state.cursor.selection(value) {
|
if let Some((start, end)) = state.cursor.selection(value) {
|
||||||
clipboard.write(
|
clipboard.write(
|
||||||
|
|
@ -1656,7 +1661,7 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
}
|
}
|
||||||
// XXX if we want to allow cutting of secure text, we need to
|
// XXX if we want to allow cutting of secure text, we need to
|
||||||
// update the cache and decide which value to cut
|
// update the cache and decide which value to cut
|
||||||
keyboard::Key::Character("x") => {
|
keyboard::Key::Character("x") | keyboard::Key::Character("X") => {
|
||||||
if !is_secure {
|
if !is_secure {
|
||||||
if let Some((start, end)) = state.cursor.selection(value) {
|
if let Some((start, end)) = state.cursor.selection(value) {
|
||||||
clipboard.write(
|
clipboard.write(
|
||||||
|
|
@ -1675,7 +1680,7 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
keyboard::Key::Character("v") => {
|
keyboard::Key::Character("v") | keyboard::Key::Character("V") => {
|
||||||
let content = if let Some(content) = state.is_pasting.take() {
|
let content = if let Some(content) = state.is_pasting.take() {
|
||||||
content
|
content
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1719,7 +1724,7 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
return event::Status::Captured;
|
return event::Status::Captured;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard::Key::Character("a") => {
|
keyboard::Key::Character("a") | keyboard::Key::Character("A") => {
|
||||||
state.cursor.select_all(value);
|
state.cursor.select_all(value);
|
||||||
return event::Status::Captured;
|
return event::Status::Captured;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue