Overview
AIR's built-in alert on the Mac looks like it comes from another decade. KlugDialog shows the real thing: native macOS alert sheets attached to your app window, with the app icon, the system font and the familiar button styles.
Beyond simple alerts it covers what desktop apps need every day: dialogs with text fields (for example user name and password, also as secure fields), several buttons with their own styles, and a progress sheet ("Connecting…") that your code updates and dismisses when the work is done.
Everything is asynchronous: show() returns at once, and your callback receives the chosen button. KlugDialog runs in the Mac version of the PetCam App, our proof of concept.
Features
- Native macOS alert sheets with up to three buttons
- Informational, warning and critical styles
- Dialogs with any number of buttons and text fields, including secure fields
- Progress sheet that can be updated and closed from code
- Dialogs can be dismissed from code
- Callbacks with the chosen button and the entered values
Supported platforms
On other platforms isSupported returns false, so your app can fall back to its usual dialogs there.
Getting started
Add the extension to your application descriptor:
<extensions>
<extensionID>com.klug.dialog.Dialog</extensionID>
</extensions>
Quick example
import com.klug.dialog.Dialog; var dialog:Dialog = Dialog.getInstance(); if ( dialog.isSupported ) // macOS { // Yes / No with result dialog.show( "Delete recording?", "This cannot be undone.", ["Delete", "Cancel"], function( index:int ):void { if ( index == 0 ) deleteRecording(); }, Dialog.STYLE_WARNING ); // sign-in dialog with two fields dialog.present( "Sign in", "Please enter your account", true, [ { label:"Sign in", style:0, tag:1 }, { label:"Cancel", style:1, tag:0 } ], [ { placeholder:"User name" }, { placeholder:"Password", secure:true } ], function( tag:int, values:Array ):void { if ( tag == 1 ) signIn( values[0], values[1] ); } ); // progress sheet, closed by code dialog.progressShow( "conn", "Connecting…", "Please wait", false ); // … later dialog.progressDismiss( "conn" ); }
API overview
| Dialog.getInstance() | Returns the single instance. |
| isSupported | True on macOS. |
| show(title, message, buttons, callback, style) | Alert sheet with up to three buttons; callback(index). |
| present(title, message, cancelable, buttons, fields, callback) | Dialog with any buttons and text fields; callback(tag, values). |
| presentDismiss(id) | Closes a dialog from code. |
| progressShow / progressUpdate / progressDismiss | Progress sheet that your code shows, updates and closes. |
| STYLE_INFO, STYLE_WARNING, STYLE_CRITICAL | Alert styles. |
Requirements
| AIR SDK | 51.x (HARMAN) |
| macOS | macOS 11 or later |