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,
)
titleA string, the title. It will not appear on screen, but will appear in the name of the thread.
textA string, the text to be displayed.
buttonsA native list of strings, the button labels. The constructor will accept up to three labels; if you need more buttons, use AddButton.
widthAn integer, one of the button width constants.
typeAn integer, one of the alert type constants.
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)
width,heightFloating point numbers.
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)
bitmapA Bitmap, the new bitmap.
textA string, the text to be displayed.
spacingAn integer, one of the button spacing constants.
widthAn integer, one of the button width constants.
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)
labelA string, the label for the new button.
keyAn optional single character string, the shortcut key for the new button.
indexAn integer, 0-based index of the button to find.
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)
invokerAn Invoker to which a message will be sent when a button is selected. If you pass the empty value, the call will be asynchronous, but the selected index will not be sent.
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)
indexAn integer, the index of a button.
shortcutA single character string, the shortcut key.
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.
- B_EMPTY_ALERT
No icon
- B_INFO_ALERT
Info icon
- B_IDEA_ALERT
Idea icon
- B_WARNING_ALERT
Warning icon
- B_STOP_ALERT
Stop icon
Button spacing
Perl
use HaikuR1::Alert qw(:button_spacing)
Python
Python does not support export tags.
- B_EVEN_SPACING
Buttons are evenly spaced
- B_OFFSET_SPACING
Leftmost button is offset
Alert inherits the following suites: