Skip to content

Fix filter typing needing two keypresses to start#783

Merged
chrxh merged 3 commits into
developfrom
claude/fix-filter-typing-focus
Jul 3, 2026
Merged

Fix filter typing needing two keypresses to start#783
chrxh merged 3 commits into
developfrom
claude/fix-filter-typing-focus

Conversation

@chrxh

@chrxh chrxh commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • The type-to-filter feature in the simulation parameters window (added in Auto-focus parameter filter on typing #779) required two keypresses: the first only moved keyboard focus into the filter field, the second actually typed.
  • Root cause: ImGui::SetKeyboardFocusHere() resolves focus at the start of the next frame, so the character queued in io.InputQueueCharacters on the triggering frame is discarded before the input widget becomes active and can consume it.
  • Fix: append the queued character(s) to _filter directly (UTF-8 encoded via ImTextCharToUtf8) and only use SetKeyboardFocusHere() to move the cursor/focus into the field for subsequent frames.

Test plan

  • build-windows-ninja.bat Release builds cleanly
  • Manually verify: open simulation parameters window, click elsewhere to defocus, type a letter — filter should populate on the first keypress

chrxh added 3 commits July 3, 2026 21:41
SetKeyboardFocusHere() only takes effect one frame later, so the
character that triggered it was lost before the input widget became
active. Append it to the filter directly instead.
Escape now clears the filter field instead of just reverting it, and
starting to type replaces the previous filter instead of appending to
it. Also drops the imgui_internal.h dependency by encoding the typed
character as UTF-8 ourselves.
The manually-spliced first character got selected by ImGui's
auto-select-on-programmatic-focus behavior, so the next keystroke
replaced it instead of appending. Replay the queued characters into
ImGui's input queue on the activation frame instead, letting ImGui's
own selection/insertion logic handle them correctly.
@chrxh chrxh marked this pull request as ready for review July 3, 2026 21:00
@chrxh chrxh merged commit c7c7d69 into develop Jul 3, 2026
1 check passed
@chrxh chrxh deleted the claude/fix-filter-typing-focus branch July 3, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant