Skip to content

Add desktop extended MessageDialog support and non-blocking macOS sheets - #108

Merged
lijy91 merged 1 commit into
mainfrom
feat/desktop-message-dialog-extended
Nov 30, 2026
Merged

lijy91 merged 1 commit into
mainfrom
feat/desktop-message-dialog-extended

Conversation

@lijy91

@lijy91 lijy91 commented Nov 30, 2026

Copy link
Copy Markdown
Member

Addresses libnativeapi/nativeapi#64.

Summary

  • Enable MessageDialog::IsExtendedSupported() across all three desktop backends (macOS, Windows Win32, Linux GTK 3):
    • macOS (NSAlert): creates a fresh NSAlert per Open(), adds configured primary / secondary / close buttons, configures Return (default) and Escape (close) key equivalents after [alert layout], maps responses to MessageDialogResult, and supports checkbox (suppressionButton), text input, and live-updating progress bar (accessoryView).
    • macOS non-blocking sheets & Close(): when SetParentWindow is set, presents via beginSheetModalForWindow:completionHandler: so the calling thread is not blocked, updates IsOpen() / GetResult() on dismissal, and implements Close() via endSheet:returnCode: (with [NSApp abortModal] for parentless modal alerts).
    • Windows (Win32): dynamically loads TaskDialogIndirect (activating a ComCtl32 v6 context via shell32.dll resource 124 when the host has no v6 manifest, falling back to MessageBoxW if unavailable), wiring custom TASKDIALOG_BUTTONs, nDefaultButton, hwndParent, checkbox, progress bar (with live updates), and Close() via TDM_CLICK_BUTTON.
    • Linux (GTK 3): uses GTK_BUTTONS_NONE + gtk_dialog_add_button + gtk_dialog_set_default_response, supports parent window, maps responses to MessageDialogResult, adds optional input/checkbox/progress widgets to the message area, and destroys modal dialogs cleanly after gtk_dialog_run.
  • Docs & tests:
    • Updated platform availability notes in src/message_dialog.h.
    • Added message_dialog_extended_test (cross-platform) and message_dialog_macos_sheet_test (macOS sheet lifecycle, custom buttons, key equivalents, live progress, and programmatic Close()).

Verification

  • macOS: message_dialog_extended_test and message_dialog_macos_sheet_test pass locally.
  • Windows & Linux: verified by CI.

@lijy91
lijy91 merged commit 9c23469 into main Nov 30, 2026
10 checks passed
@lijy91
lijy91 deleted the feat/desktop-message-dialog-extended branch November 30, 2026 23:52
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