Skip to content

Commit

Permalink
fix(input): handle space named key
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 authored and jackpot51 committed Feb 9, 2024
1 parent f9d2e58 commit 5738ac2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/widget/text_input/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ where
return event::Status::Captured;
}
}
Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
Event::Keyboard(keyboard::Event::KeyPressed { key, text, .. }) => {
let state = state();

if let Some(focus) = &mut state.is_focused {
Expand Down Expand Up @@ -1489,19 +1489,24 @@ where

state.keyboard_modifiers = keyboard::Modifiers::default();
}
keyboard::Key::Named(keyboard::key::Named::Tab)
| keyboard::Key::Named(keyboard::key::Named::ArrowUp)
| keyboard::Key::Named(keyboard::key::Named::ArrowDown) => {
keyboard::Key::Named(
keyboard::key::Named::Tab
| keyboard::key::Named::ArrowUp
| keyboard::key::Named::ArrowDown,
) => {
return event::Status::Ignored;
}
keyboard::Key::Character(c) => {
keyboard::Key::Character(_)
| keyboard::Key::Named(keyboard::key::Named::Space) => {
if state.is_pasting.is_none()
&& !state.keyboard_modifiers.command()
&& !modifiers.control()
{
let mut editor = Editor::new(unsecured_value, &mut state.cursor);

editor.insert(c.chars().next().unwrap_or_default());
editor.insert(
text.unwrap_or_default().chars().next().unwrap_or_default(),
);
let contents = editor.contents();
let unsecured_value = Value::new(&contents);
let message = (on_input)(contents);
Expand Down

0 comments on commit 5738ac2

Please sign in to comment.