← All extensions

Native extension

KlugDialog

com.klug.dialog.Dialog

NO APM NEEDED. Download and enjoy. It can’t get any simpler. Just update the Adobe AIR SDK. If you need help, we are here.

Native dialogs for AIR apps on Android, iOS and macOS: alerts, dialogs with text fields that stay above the keyboard, and a progress dialog that your code updates and closes.

AndroidiOSmacOS In production From €9 / year · Buy

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 our apps, our proof of concept.

New on Android: the same dialogs as native Android dialogs. Text fields stay above the keyboard on every screen, also in landscape on tablets, where the buttons used to disappear behind it; passwords, user names and e-mail addresses are never auto-capitalised, and e-mail fields get the e-mail keyboard. The Android version also stacks long button lists and offers a plain spinner, and runs in the Android version of our apps.

Also on iOS: since version 1.2 the same API shows native iOS alerts, dialogs with text fields and a progress dialog, so one code path serves Android, iOS and macOS.

Features

  • Self-contained: one ANE, no core library or dependency ANEs to add
  • 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
  • Android: fields above the keyboard, no auto-capitalised passwords, e-mail / number keyboards, light and dark theme

Supported platforms

Android alerts · text fields · progress · long button lists
iOS arm64 · alerts · text fields · progress
macOS arm64 · x86_64

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:

app.xml
<extensions>
    <extensionID>com.klug.dialog.Dialog</extensionID>
</extensions>

Code examples

Five complete flows. Every call returns at once; the result arrives later in your callback, so the app never blocks while a dialog is open. Full documentation →

1 · Check support and show a simple alert
Setup.as
import com.klug.dialog.Dialog;

var dialog:Dialog = Dialog.getInstance();

if ( dialog.isSupported )
{
    dialog.show( "Saved", "The recording is in your library." );   // one "OK" button
}
else
{
    showAppAlert( "Saved" );   // your app's own fallback dialog, e.g. on Windows
}
2 · Ask a question with up to three buttons
Confirm.as
dialog.show( "Delete recording?", "This cannot be undone.",
    [ "Delete", "Keep" ],
    function( index:int ):void
    {
        // index = position in the buttons array;
        // -1 = closed without a button, e.g. the Android back key
        if ( index == 0 ) deleteRecording();   // your app
    },
    Dialog.STYLE_WARNING );   // alert style of the macOS sheet
3 · Sign-in dialog with text fields
SignIn.as
var buttons:Array = [
    { label:"Cancel",  style:4, tag:0 },   // style 4 = cancel, 3 = destructive
    { label:"Sign in", style:0, tag:1 }
];
var fields:Array = [
    { placeholder:"E-mail", text:lastEmail, keyboardType:7 },   // 7 = e-mail keyboard
    { placeholder:"Password", secure:true }                 // never auto-capitalised
];

dialog.present( "Sign in", "Please enter your account.", true, buttons, fields,
    function( tag:int, values:Array, cancelled:Boolean = false ):void
    {
        if ( cancelled ) return;   // closed without a button (tag -1)
        if ( tag == 1 ) signIn( values[0], values[1] );   // values in field order
    },
    null, "dark" );   // theme on Android and iOS; macOS follows the system
4 · Progress dialog while your code works
Connect.as
// your own id: the same dialog is updated and closed with it
dialog.progressShow( "connect", "Connecting", "Contacting the server…", false,
    function():void { trace( "progress dialog closed" ); } );   // fires once

dialog.progressUpdate( "connect", "Signing in…" );

// when the work is done, or has failed
dialog.progressDismiss( "connect" );
5 · Close a dialog from code
Waiting.as
// pass your own id as the 7th parameter to close the dialog later
dialog.present( "Waiting for the camera", "Tap Cancel to stop waiting.", false,
    [ { label:"Cancel", style:4, tag:0 } ], null,
    function( tag:int, values:Array ):void { stopWaiting(); },   // your app
    "waitCamera" );

// the camera has answered: close the dialog, no callback fires
dialog.presentDismiss( "waitCamera" );

API overview

Dialog.getInstance()Returns the single instance.
isSupportedTrue on Android, iOS and macOS; false elsewhere, for example on Windows.
show(title, message, buttons, callback, style)Alert with up to three buttons (default "OK"); callback(index), -1 if closed without a button. Returns false if unsupported.
present(title, message, cancelable, buttons, fields, callback, id, theme)Dialog with any number of buttons and text fields; callback(tag, values, cancelled). Pass your own id to close it later; theme "light" or "dark" on Android and iOS.
presentDismiss(id)Closes a present() dialog from code; no callback fires.
progressShow(id, title, message, cancelable, closeCallback, theme)Progress dialog with a spinner; closeCallback fires once when it is gone.
progressUpdate(id, message) / progressDismiss(id)Changes the text of the progress dialog / closes it.
STYLE_INFO, STYLE_WARNING, STYLE_CRITICALAlert styles for show(), used by the macOS alert sheet.
Button {label, style, tag}style: 0 default, 1 positive, 2 negative, 3 destructive, 4 cancel, 5 neutral. Android uses all of them, iOS uses 3 and 4, macOS shows all buttons alike.
Field {placeholder, secure, text, keyboardType, autocorrect, autocap}keyboardType: 0 default, 3 URL, 4 number, 5 phone, 7 e-mail, 8 decimal. autocap: 0 none (default), 1 sentences, 2 words, 3 all. The last three apply on Android and iOS.

Buy KlugDialog

A yearly licence for one AIR application, with all updates for 12 months. After payment you receive the extension, the ActionScript library and the documentation by e-mail, usually within one business day. Licence and terms

Simple
€9 / year
  • Licence for one AIR application
  • All updates for 12 months
  • No support
Buy Simple
Standard
€39 / year
  • Licence for one AIR application
  • All updates for 12 months
  • Answer by e-mail within 7 days
Buy Standard
Priority
€79 / year
  • Licence for one AIR application
  • All updates for 12 months
  • Answer by e-mail within 48 hours
Buy Priority
Taxes are calculated at checkout by Link (Stripe). You enter the application ID of your AIR app during checkout.

Requirements

AIR SDK51.x (HARMAN)
AndroidAndroid 6 or later
iOSiOS 13 or later
macOSmacOS 11 or later