Haiku API Bindings
Alert
Not logged in

Documentation | InterfaceKit | Alert

SYNOPSIS

Perl

Python

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();

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

Python

HaikuR1::Alert->new(
    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

Python

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

Appearance

SetIcon

SetText

SetButtonSpacing

SetButtonWidth

Changes elements of the Alert's appearance.

Perl

Python

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

Buttons

AddButton

CountButtons

ButtonAt

These buttons do what you expect.

Perl

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

Python

$alert->Go($invoker);

Shortcut

SetShortcut

Gets or sets a shortcut character for a button.

Perl

Python

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

TextView

Returns the TextView object for the Alert's text.

Perl

Python

$alert->TextView();

Type

SetType

Gets or sets the alert type.

Perl

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

Python

use HaikuR1::Alert qw(:alert_type)

No icon

Info icon

Idea icon

Warning icon

Stop icon

Button spacing

Perl

Python

use HaikuR1::Alert qw(:button_spacing)

Buttons are evenly spaced

Leftmost button is offset

Alert inherits the following suites: