Repository navigation
Description
Environment
- Package / Binding:
nativeapi-core(via Dart / Flutternativeapi/cnativeapi) - Version:
0.6.2/main - OS: macOS, Windows, Linux
Summary
While integrating MessageDialog into a Flutter desktop app, I noticed two limitations in the desktop implementations:
1. Custom buttons aren't supported on any of the three desktop backends.
message_dialog_extensions.inc already defines SetButtons(primary, secondary, close), SetDefaultButton, and SetParentWindow. However, MessageDialog::IsExtendedSupported() currently returns false on macOS, Windows (Win32), and Linux.
As a result, each platform falls back to a single OK button (NSAlert default, MB_OK | MB_ICONINFORMATION, and GTK_BUTTONS_OK respectively).
2. macOS MessageDialog blocks the calling thread.
message_dialog_macos.mm uses [ns_alert runModal] for all modalities. In apps where UI and script execution share the main thread (such as Flutter), this blocks rendering until the user dismisses the alert. Close() also can't currently dismiss an open dialog programmatically.
(I also noticed that ios/message_dialog_ios.mm appears to be a stub. Happy to look into that separately after the desktop changes.)
Proposed Plan
If these are areas the project is open to improving, I'd be happy to contribute PRs for both.
1. Add extended button support to desktop backends (IsExtendedSupported() = true)
This would use the existing state in message_dialog_extensions.inc, without requiring changes to the C ABI or codegen.
- Windows (Win32): Use
TaskDialogIndirectwithTASKDIALOG_BUTTONentries andnDefaultButton. - macOS: Add buttons using
addButtonWithTitle:and configure the key equivalent for the default button. - Linux: Use
GTK_BUTTONS_NONE, add each configured button withgtk_dialog_add_button, and set the default response withgtk_dialog_set_default_responseon the current GTK 3 backend. This can be updated toGtkAlertDialogwhenlibnativeapi/nativeapi-core#103lands. - Add a multi-button example under
examples/to test button labels, Return/Escape handling, and returned results across all three platforms.
2. Make macOS sheet dialogs non-blocking
- When a parent window is provided, present the alert using
beginSheetModalForWindow:completionHandler:and return the result through the completion handler. - Implement
Close()using[parentWindow endSheet:]. - Keep
runModalfor cases where no parent window is provided, as documented.
Activity
lijy91 commentedon Nov 30, 2026
Implemented and merged in libnativeapi/nativeapi-core#108:
MessageDialogsupport (IsExtendedSupported() == true) across macOS, Windows (Win32), and Linux (GTK 3) without changing the C ABI:NSAlert): freshNSAlertperOpen(), customprimary/secondary/closebuttons, Return (default) and Escape (close) key equivalents configured after[alert layout], result mapping, plus checkbox, text input, and live-updating progress bar.Close(): usesbeginSheetModalForWindow:completionHandler:whenSetParentWindowis set, updatesIsOpen()/GetResult()in the completion handler, and dismisses viaendSheet:returnCode:(keepingrunModalwhen no parent window is set).TaskDialogIndirect(with a ComCtl32 v6 activation context fallback for manifest-less hosts, falling back toMessageBoxWif unavailable) with customTASKDIALOG_BUTTONs,nDefaultButton,hwndParent, checkbox, progress bar, and programmaticClose().GTK_BUTTONS_NONE+gtk_dialog_add_button+gtk_dialog_set_default_response, parent window support, result mapping, and optional input/checkbox/progress controls.nativeapi-core).Feel free to open a separate issue or PR if you'd like to follow up on iOS (
message_dialog_ios.mm). Thanks for the detailed report and design!