Fix impossible to type v in TextInput
This commit is contained in:
parent
416e0026c0
commit
b544c90812
1 changed files with 29 additions and 34 deletions
|
|
@ -886,42 +886,38 @@ where
|
||||||
|
|
||||||
update_cache(state, value);
|
update_cache(state, value);
|
||||||
}
|
}
|
||||||
keyboard::Key::Character("v") => {
|
keyboard::Key::Character("v")
|
||||||
if state.keyboard_modifiers.command()
|
if state.keyboard_modifiers.command()
|
||||||
&& !state.keyboard_modifiers.alt()
|
&& !state.keyboard_modifiers.alt() =>
|
||||||
{
|
{
|
||||||
let content = match state.is_pasting.take() {
|
let content = match state.is_pasting.take() {
|
||||||
Some(content) => content,
|
Some(content) => content,
|
||||||
None => {
|
None => {
|
||||||
let content: String = clipboard
|
let content: String = clipboard
|
||||||
.read()
|
.read()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.chars()
|
.chars()
|
||||||
.filter(|c| !c.is_control())
|
.filter(|c| !c.is_control())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Value::new(&content)
|
Value::new(&content)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut editor =
|
let mut editor = Editor::new(value, &mut state.cursor);
|
||||||
Editor::new(value, &mut state.cursor);
|
|
||||||
|
|
||||||
editor.paste(content.clone());
|
editor.paste(content.clone());
|
||||||
|
|
||||||
let message = if let Some(paste) = &on_paste {
|
let message = if let Some(paste) = &on_paste {
|
||||||
(paste)(editor.contents())
|
(paste)(editor.contents())
|
||||||
} else {
|
|
||||||
(on_input)(editor.contents())
|
|
||||||
};
|
|
||||||
shell.publish(message);
|
|
||||||
|
|
||||||
state.is_pasting = Some(content);
|
|
||||||
|
|
||||||
update_cache(state, value);
|
|
||||||
} else {
|
} else {
|
||||||
state.is_pasting = None;
|
(on_input)(editor.contents())
|
||||||
}
|
};
|
||||||
|
shell.publish(message);
|
||||||
|
|
||||||
|
state.is_pasting = Some(content);
|
||||||
|
|
||||||
|
update_cache(state, value);
|
||||||
}
|
}
|
||||||
keyboard::Key::Character("a")
|
keyboard::Key::Character("a")
|
||||||
if state.keyboard_modifiers.command() =>
|
if state.keyboard_modifiers.command() =>
|
||||||
|
|
@ -945,12 +941,11 @@ where
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(text) = text {
|
if let Some(text) = text {
|
||||||
|
state.is_pasting = None;
|
||||||
|
|
||||||
let c = text.chars().next().unwrap_or_default();
|
let c = text.chars().next().unwrap_or_default();
|
||||||
|
|
||||||
if state.is_pasting.is_none()
|
if !c.is_control() {
|
||||||
&& !state.keyboard_modifiers.command()
|
|
||||||
&& !c.is_control()
|
|
||||||
{
|
|
||||||
let mut editor =
|
let mut editor =
|
||||||
Editor::new(value, &mut state.cursor);
|
Editor::new(value, &mut state.cursor);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue