Focus command palette filter input on open

This commit is contained in:
MihneaTeodorStoica 2025-11-08 17:48:44 +02:00
parent 7b603cc6d8
commit 8ed71f40dc
3 changed files with 7 additions and 0 deletions

View file

@ -208,6 +208,10 @@ pub fn draw_command_palette(ctx: &mut Context, state: &mut State) {
if ctx.editline("command-filter", &mut state.command_palette_filter) {
state.command_palette_selection = 0;
}
if state.command_palette_focus_filter {
state.command_palette_focus_filter = false;
ctx.steal_focus();
}
ctx.block_end();
let entries = build_command_entries(state);

View file

@ -361,6 +361,7 @@ fn draw(ctx: &mut Context, state: &mut State) {
state.command_palette_filter.clear();
state.command_palette_selection = 0;
state.command_palette_reset_selection = true;
state.command_palette_focus_filter = true;
ctx.needs_rerender();
return;
} else if key == kbmod::CTRL | vk::N {

View file

@ -186,6 +186,7 @@ pub struct State {
pub command_palette_filter: String,
pub command_palette_selection: usize,
pub command_palette_reset_selection: bool,
pub command_palette_focus_filter: bool,
system_palette: [StraightRgba; INDEXED_COLORS_COUNT],
}
@ -245,6 +246,7 @@ impl State {
command_palette_filter: String::new(),
command_palette_selection: 0,
command_palette_reset_selection: false,
command_palette_focus_filter: false,
system_palette: framebuffer::DEFAULT_THEME,
})
}