fix: not sure what happened on this
1 file changed, +14 -11
+14-11src/widgets/miller.rs
| @@ -176,19 +176,22 @@ impl MillerFilter { | ||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | let has_focus = r.has_focus(); |
| 179 | + let lost_focus = r.lost_focus(); | |
| 179 | 180 | |
| 180 | - if has_focus { | |
| 181 | - // Escape: unfocus (don't clear) | |
| 182 | - if ui.input(|i| i.key_pressed(egui::Key::Escape)) { | |
| 183 | - r.surrender_focus(); | |
| 181 | + if has_focus || lost_focus { | |
| 182 | + if has_focus { | |
| 183 | + // Escape: unfocus (don't clear) | |
| 184 | + if ui.input(|i| i.key_pressed(egui::Key::Escape)) { | |
| 185 | + r.surrender_focus(); | |
| 186 | + } | |
| 187 | + // Ctrl-N / ArrowDown | |
| 188 | + resp.next = ui.input(|i| i.key_pressed(egui::Key::ArrowDown)) | |
| 189 | + || ui.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::N)); | |
| 190 | + // Ctrl-P / ArrowUp | |
| 191 | + resp.prev = ui.input(|i| i.key_pressed(egui::Key::ArrowUp)) | |
| 192 | + || ui.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::P)); | |
| 184 | 193 | } |
| 185 | - // Ctrl-N / ArrowDown | |
| 186 | - resp.next = ui.input(|i| i.key_pressed(egui::Key::ArrowDown)) | |
| 187 | - || ui.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::N)); | |
| 188 | - // Ctrl-P / ArrowUp | |
| 189 | - resp.prev = ui.input(|i| i.key_pressed(egui::Key::ArrowUp)) | |
| 190 | - || ui.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::P)); | |
| 191 | - // Enter | |
| 194 | + // Enter (check both has_focus and lost_focus since TextEdit surrenders on Enter) | |
| 192 | 195 | if ui.input(|i| i.key_pressed(egui::Key::Enter)) { |
| 193 | 196 | resp.accept = true; |
| 194 | 197 | } |