Haiku API Bindings
Alert
Not logged in

Documentation | InterfaceKit | Alert

SYNOPSIS

Perl

use HaikuR1::Alert qw(B_EMPTY_ALERT B_INFO_ALERT B_IDEA_ALERT B_WARNING_ALERT B_STOP_ALERT B_EVEN_SPACING B_OFFSET_SPACING);

my $alert = HaikuR1::Alert->new(
    title => $title,
    text => $text,
    buttons => $buttons,
    width => $width,
    type => $type,
);
$alert->Go();

Python

fromm HaikuR1.InterfaceKit import Alert, B_EMPTY_ALERT, B_INFO_ALERT, B_IDEA_ALERT, B_WARNING_ALERT, B_STOP_ALERT, B_EVEN_SPACING, B_OFFSET_SPACING

alert = Alert(
    title = title,
    text = text,
    buttons = buttons,
    width = width,
    type = type,
)
$alert->Go()

DESCRIPTION

Exposes the BAlert object.

For more information on Alert, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates an Alert.

Perl

HaikuR1::Alert->new(
    title => $title,
    text => $text,
    buttons => $buttons,
    width => $width,
    type => $type,
);

Python

Alert(
    title = title,
    text = text,
    buttons = buttons,
    width = width,
    type = type,
)

AlertPosition

Computes the frame given the width and height and returns the upper left Point.

Unless you are creating your own custom Alert subclass, you should not need this method; the constructor calls it automatically.

Perl

$alert->AlertPosition($width, $height);

Python

alert.AlertPosition(width, height)

Appearance

SetIcon

SetText

SetButtonSpacing

SetButtonWidth

Changes elements of the Alert's appearance.

Perl

$alert->SetIcon($bitmap);
$alert->SetText($text);
$alert->SetButtonSpacing($spacing);
$alert->SetButtonWidth($width);

Python

alert.SetIcon(bitmap)
alert.SetText(text)
alert.SetButtonSpacing(spacing)
alert.SetButtonWidth(width)

Buttons

AddButton

CountButtons

ButtonAt

These buttons do what you expect.

Perl

$alert->AddButton($label, $key);
$alert->CountButtons();
$alert->ButtonAt($index);

Python

alert.AddButton(label, key)
alert.CountButtons()
alert.ButtonAt(index)

Go

Displays the Alert.

If an Invoker is provided, the call will be asynchronous: it will return 0 immediately and a message will be sent to the Invoker's target. The 0-based index of the selected button will be in the int32 "which" field of the message.

If no Invoker is provided, the call will be synchronous: it will not return until the user has selected a button, and the return value will be the index of the selected button.

Perl

$alert->Go($invoker);

Python

alert.Go(invoker)

Shortcut

SetShortcut

Gets or sets a shortcut character for a button.

Perl

$alert->Shortcut($index);
$alert->SetShortcut($index, $shortcut);

Python

alert.SetShortcut(index, shortcut)
alert.Shortcut(index)

TextView

Returns the TextView object for the Alert's text.

Perl

$alert->TextView();

Python

alert.TextView()

Type

SetType

Gets or sets the alert type.

Perl

$alert->Type();
$alert->SetType($type);

Python

alert.Type()
alert.SetType(type)

ARCHIVABLE INTERFACE

Alert inherits the methods and hooks of Archivable.

HANDLER INTERFACE

Alert inherits the methods and hooks of Handler.

LOOPER INTERFACE

Alert inherits the methods and hooks of Looper.

WINDOW INTERFACE

Alert inherits the methods and hooks of Window.

CONSTANTS

Alert types

Perl

use HaikuR1::Alert qw(:alert_type)

Python

Python does not support export tags.

No icon

Info icon

Idea icon

Warning icon

Stop icon

Button spacing

Perl

use HaikuR1::Alert qw(:button_spacing)

Python

Python does not support export tags.

Buttons are evenly spaced

Leftmost button is offset

Alert inherits the following suites: