Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set focus better on Ctrl+F #4230

Merged
merged 2 commits into from
Oct 11, 2024
Merged

Set focus better on Ctrl+F #4230

merged 2 commits into from
Oct 11, 2024

Conversation

HebaruSan
Copy link
Member

Problems

  • Ctrl+F is supposed to focus the search box, but currently it doesn't
  • Even if we fix the broken Ctrl+F handler, it will only work when the mod grid has focus, not mod info or any of the other parts of the UI

Cause

  • Going back to a3d96f6, the focus has been set solely by setting ActiveControl, which doesn't always work (details unclear, but possibly related to the search control containing sub-controls?)
  • Ctrl+F is currently handled by ManageMods.ProcessCmdKey, which is only called when that control has focus

Changes

  • Now .Focus() is used to set the focus
  • Now the handler for the Ctrl+F keystroke is moved from ManageMods back to Main so it can be global
    • Now ManageMods implements a new ISearchableControl interface to advertise its ability to respond to Ctrl+F keystroke, which Main then uses to find a control
  • Courtesy of a VSCode performance-improvement suggestion, many usages of .Any() are replaced by checking .Count instead

After this, Ctrl+F sets the focus to the search box whenever it's visible, and if other controls (Edit Modpack, Unmanaged Files, etc.) add their own search tools in the future, they can implement ISearchableControl.

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI labels Oct 11, 2024
@HebaruSan HebaruSan merged commit 4c31279 into KSP-CKAN:master Oct 11, 2024
3 checks passed
@HebaruSan HebaruSan deleted the fix/ctrl-f branch October 11, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant