diff --git a/src/input/keyboard.rs b/src/input/keyboard.rs index a12b704..3c0ef09 100644 --- a/src/input/keyboard.rs +++ b/src/input/keyboard.rs @@ -245,28 +245,26 @@ impl AppData } Keysym::Down | Keysym::Up => { - // When a text input is focused, Up/Down move the cursor - // between lines first. They only fall through to list - // hover-navigation (combo / scrollable list) when the - // cursor was already on the topmost / bottommost line — - // that lets a user keyboard-step out of a multiline - // `text_edit` into surrounding navigable items without - // changing focus first. let is_text = focused.and_then( |idx| find_handlers( &self.surface( focus ).widget_rects, idx ) .map( |h| h.is_text_input() ) ).unwrap_or( false ); let reverse = event.keysym == Keysym::Up; let extend = self.shift_pressed; - let consumed = if is_text + let intercepted = self.app.on_key_with_modifiers( event.keysym, self.ctrl_pressed, self.shift_pressed ); + if let Some( msg ) = intercepted { - if reverse { self.handle_cursor_up( focus, extend ) } - else { self.handle_cursor_down( focus, extend ) } - } else { false }; - if !consumed && !self.move_keyboard_hover( focus, reverse ) + self.pending_msgs.push( msg ); + } + else { - if let Some( msg ) = self.app.on_key_with_modifiers( event.keysym, self.ctrl_pressed, self.shift_pressed ) + let consumed = if is_text { - self.pending_msgs.push( msg ); + if reverse { self.handle_cursor_up( focus, extend ) } + else { self.handle_cursor_down( focus, extend ) } + } else { false }; + if !consumed && !self.move_keyboard_hover( focus, reverse ) + { + // already None, no extra fire } } } @@ -276,7 +274,12 @@ impl AppData find_handlers( &self.surface( focus ).widget_rects, idx ) .map( |h| h.is_text_input() ) ).unwrap_or( false ); let extend = self.shift_pressed; - if is_text + let intercepted = self.app.on_key_with_modifiers( event.keysym, self.ctrl_pressed, self.shift_pressed ); + if let Some( msg ) = intercepted + { + self.pending_msgs.push( msg ); + } + else if is_text { if event.keysym == Keysym::Left { @@ -284,9 +287,6 @@ impl AppData } else { self.handle_cursor_right( focus, extend ); } - } else if let Some( msg ) = self.app.on_key_with_modifiers( event.keysym, self.ctrl_pressed, self.shift_pressed ) - { - self.pending_msgs.push( msg ); } } Keysym::Home => @@ -334,11 +334,19 @@ impl AppData Keysym::Tab | Keysym::ISO_Left_Tab => { let reverse = event.keysym == Keysym::ISO_Left_Tab || self.shift_pressed; - let ss = self.surface( focus ); - let next_idx = next_focusable_index( &ss.widget_rects, ss.focused_idx, reverse ); - if let Some( next_idx ) = next_idx + let intercepted = self.app.on_key_with_modifiers( event.keysym, self.ctrl_pressed, self.shift_pressed ); + if let Some( msg ) = intercepted { - self.set_focus( focus, Some( next_idx ), qh ); + self.pending_msgs.push( msg ); + } + else + { + let ss = self.surface( focus ); + let next_idx = next_focusable_index( &ss.widget_rects, ss.focused_idx, reverse ); + if let Some( next_idx ) = next_idx + { + self.set_focus( focus, Some( next_idx ), qh ); + } } } Keysym::Escape =>