FutureBasic Logo

<<    Index    >> FutureBasic

alert   statement / function



Statement syntax
alert tag, style, message, informativeText, buttonTitles, sheetFlag

Function syntax
response = alert tag, style, message, informativeText, buttonTitles

Description
Use this statement/function to:
  • Create a new alert dialog;
  • Show or hide an existing alert;
  • Alter an existing alert's characteristics.

  • Parameters
    Parameter
    Description
    tag A number (1 through 1000000) that you assign when you create the alert and that you refer to when altering the alert. A negative tag hides the alert.
    style The alert style:
    NSAlertStyleWarning (default)
    NSAlertStyleInformational
    NSAlertStyleCritical
    message The alert's message text as a CFStringRef or an ErrorRef.
    informativeText The alert's info text as a CFStringRef.
    buttonTitles A semicolon-delimited CFStringRef or a CFArrayRef of button titles.
    sheetFlag A boolean value to indicate if the alert will be a sheet attached to the current output window.
    Note An alert sheet does not return a response value from the alert statement, but instead posts an _alertDidEnd event to the user on dialog function.
     
    Return value
    NSAlertFirstButtonReturn The user clicked the first (rightmost) button on the dialog or sheet. This return value = 1000.
    NSAlertSecondButtonReturn The user clicked the second button from the right edge of the dialog or sheet. This return value = 1001.
    NSAlertThirdButtonReturn The user clicked the third button from the right edge of the dialog or sheet. This return value = 1002.
    NSAlertThirdButtonReturn + n Subsequent button clicks.
     

    Example 1 - panel

    long retVal

    retVal = alert 1, NSAlertStyleCritical, @"My alert message", @"My alert info", @"OK;Cancel"
    select ( retVal )
    case NSAlertFirstButtonReturn // OK button
    // ...
    case NSAlertSecondButtonReturn // Cancel button
    // ...
    end select

    HandleEvents

    Example 2 - sheet

    When the alert is a sheet, its return value must be picked up in the user on dialog function's _alertDidEnd event.

    window 1

    alert 101, NSAlertStyleCritical, @"My alert message", @"My alert info", @"OK;Cancel", YES

    void local fn DoDialog( ev as long, tag as long, wnd as long )
    select ( ev )
    case _alertDidEnd
    select ( wnd ) // wnd = alert panel num
    case 101
    select ( tag ) // tag = response
    case NSAlertFirstButtonReturn // OK button
    // ...
    case NSAlertSecondButtonReturn // Cancel Button
    // ...
    end select
    end select
    end select
    end fn

    on dialog fn DoDialog

    HandleEvents
     
    Ancillary functions
    The following optional functions enhance the alert panel and should be called before the alert statement.
    AlertSetAccessoryView
    AlertSetShowsHelp
    AlertSetHelpAnchor
    AlertSetShowsSuppressionButton
    AlertSuppressionButtonSetTitle
    AlertSetIcon
    AlertSetIconNamed
    AlertButtonSetKeyEquivalent
    AlertButtonSetKeyEquivalentModifierMask
    AlertButtonsSetHidden
     
    Dialog events
    _alertDidEnd
    _alertShowHelp

     
    Apple documentation
    NSAlert
    NSAlertDelegate