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

Work around OpenFileDialog always showing all shortcuts despite filters #4168

Merged

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Aug 21, 2024

Problem

The popup to add a game instance is only supposed to let the user choose game executable files of known games, but it always shows all shortcuts:

image

If you choose one of these and try to use it to add a game instance, you get a (quite funny) "Catastrophic failure" message:

image

Reported by @PoofImAlex in #4167.

Cause

This seems to be just how OpenFileDialog "works". I'm sure there's some obscure rationale for it in some Microsoft document somewhere, but it is truly inappropriate and in need of fixing in our case.

Changes

It seems to be impossible to hide shortcuts, so instead we hook into the FileOk event and reject any files that don't match the filter that we already gave to OpenFileDialog but which it decided to partially ignore:

image

@HebaruSan HebaruSan added Bug GUI Issues affecting the interactive GUI Windows Issues specific for Windows labels Aug 21, 2024
@HebaruSan HebaruSan merged commit 2fc36b4 into KSP-CKAN:master Aug 21, 2024
3 checks passed
@HebaruSan HebaruSan deleted the fix/openfiledialog-shortcut-workaround branch August 21, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GUI Issues affecting the interactive GUI Windows Issues specific for Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant