Skip to content

fix(windows): support custom dialog button callbacks via TaskDialog API#5193

Draft
leaanthony wants to merge 1 commit intomasterfrom
fix/4402-windows-dialog-buttons
Draft

fix(windows): support custom dialog button callbacks via TaskDialog API#5193
leaanthony wants to merge 1 commit intomasterfrom
fix/4402-windows-dialog-buttons

Conversation

@leaanthony
Copy link
Copy Markdown
Member

Summary

  • Implement Windows TaskDialog API (TaskDialogIndirect from comctl32.dll) for dialogs with custom buttons, enabling AddButton and SetDefaultButton callbacks to actually fire on Windows
  • Add case-insensitive button label matching in the fallback MessageBox path
  • Fall back to MessageBox API on systems where TaskDialog is unavailable (pre-Vista)
  • Add comprehensive tests for button callbacks, case-insensitive matching, custom labels, and Unicode support

The root cause was that Windows MessageBox API only supports a fixed set of predefined buttons (OK, Cancel, Yes, No). Custom button labels like "Quit" were never matched against the predefined responses, so callbacks never fired. The TaskDialog API (available since Vista) supports arbitrary button labels.

Fixes #4402

Test plan

  • TestWindowsDialogButtonCallbacks — OK button, case-insensitive matching, multiple buttons, whitespace handling
  • TestDialogButtonTypes — Info, Error, Warning, Question dialog types
  • TestCustomButtonLabels — custom labels, emoji/Unicode, default/cancel flags
  • Example code in tests/windows_dialog_callback_example.go

Note: Runtime tests require Windows. The unit tests verify callback wiring without showing dialogs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 76d29b88-1d7f-4cae-9665-329919fe67b9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4402-windows-dialog-buttons

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Windows dialogs with custom buttons and OnClick callbacks were silently
ignored because MessageBox only supports predefined button sets (OK, Yes,
No, etc.). Users could add buttons with custom labels but callbacks never
fired.

Use TaskDialogIndirect (comctl32.dll, Vista+) when custom buttons are
present, which supports arbitrary button labels and proper callback
dispatch by button ID. Falls back to the existing MessageBox path when
no custom buttons are defined.

Fixes #4402
@leaanthony leaanthony force-pushed the fix/4402-windows-dialog-buttons branch from 631071c to 21683cd Compare April 21, 2026 16:42
@leaanthony leaanthony changed the base branch from v3-alpha to master April 29, 2026 13:07
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.

V3: Cannot set Windows Dialog button callback

1 participant