Skip to content

File widget: use SDL_ShowOpenFileDialog() when SDL backend is active #213

@RobLoach

Description

@RobLoach

When the file widget is built against the SDL backend (nuklear_console_file_system.h), file browsing today still goes through the in-widget list view. SDL3 ships a native picker API — SDL_ShowOpenFileDialog() (plus SDL_ShowSaveFileDialog() and SDL_ShowOpenFolderDialog()) — that hands off to the platform's real file chooser. Using it would feel more native on Linux/macOS/Windows and would also resolve the keyboard/gamepad navigation edge cases the in-widget browser carries.

Refs:

Suggested Implementation

  • Add an opt-in macro NK_CONSOLE_FILE_SDL_NATIVE_DIALOG (default off to preserve current behavior) gated by NK_CONSOLE_ENABLE_SDL3 / equivalent.
  • When set, nk_console_file / nk_console_dir / nk_console_file_action skip the in-widget list view; on activation, they call SDL_ShowOpenFileDialog (or SDL_ShowOpenFolderDialog for dir, SDL_ShowSaveFileDialog for the save-action variant).
  • Wire the SDL_DialogFileCallback to copy the chosen path into the existing file-path buffer and fire NK_CONSOLE_EVENT_CHANGED.
  • Route any nk_console_file_set_filter extensions (File: Extension Filter #175) through SDL_DialogFileFilter[] so the native dialog honors the same filter spec.
  • Document the new macro in the README Configuration table.

QA

  • demo/sdl3_renderer with the macro enabled opens the platform's native file picker on click.
  • With the macro unset, the existing in-widget browser still works (no behavior change for current users).
  • Save-action variant returns a path even when the chosen filename doesn't yet exist on disk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions