Skip to content

Commit

Permalink
Simplify filtering when not focused
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Jan 12, 2024
1 parent e9558e4 commit c1944f9
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/text_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,7 @@ where
Event::Keyboard(KeyEvent::KeyPressed {
key_code,
modifiers,
}) => {
// Only parse keys when focused
if state.is_focused {
}) if state.is_focused => {
match key_code {
KeyCode::Left => {
editor.action(Action::Motion(Motion::Left));
Expand Down Expand Up @@ -768,14 +766,11 @@ where
}
_ => (),
}
}
}
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
state.modifiers = modifiers;
}
Event::Keyboard(KeyEvent::CharacterReceived(character)) => {
// Only parse keys when focused
if state.is_focused {
Event::Keyboard(KeyEvent::CharacterReceived(character)) if state.is_focused => {
// Only parse keys when Super, Ctrl, and Alt are not pressed
if !state.modifiers.logo()
&& !state.modifiers.control()
Expand All @@ -786,7 +781,6 @@ where
}
status = Status::Captured;
}
}
}
Event::Mouse(MouseEvent::ButtonPressed(button)) => {
if let Some(p) = cursor_position.position_in(layout.bounds()) {
Expand Down

0 comments on commit c1944f9

Please sign in to comment.