NAME
TUI::Dialogs::Button - pushbutton control for Turbo Vision dialogs
HIERARCHY
TObject
TView
TButton
SYNOPSIS
use TUI::Dialogs;
use TUI::Objects;
my $dialog = TDialog->new(
bounds => TRect->new(ax => 10, ay => 4, bx => 44, by => 15),
title => 'Confirm'
);
my $ok = TButton->new(
bounds => TRect->new(ax => 7, ay => 8, bx => 17, by => 10),
title => '~O~K',
command => cmOK,
flags => bfDefault
);
my $cancel = TButton->new(
bounds => TRect->new(ax => 19, ay => 8, bx => 31, by => 10),
title => '~C~ancel',
command => cmCancel,
flags => bfNormal
);
$dialog->insert($ok);
$dialog->insert($cancel);
my $result = $deskTop->execView($dialog);
DESCRIPTION
TButton implements an interactive pushbutton control with full Turbo Vision semantics. It supports highlighting, shadow rendering, pressing behavior, default-button logic, and command dispatch.
Mouse and keyboard events are handled according to the original Turbo Vision model.
Commonly Used Features
Most applications use TButton as a dialog control: create a button with title/command/flags, insert it into a TDialog, then react to the command returned by execView(). Typical setups include one default action button (bfDefault) and one normal cancel button (bfNormal).
In day-to-day use you rarely call low-level methods directly; handleEvent(), draw(), and default-button behavior are managed by the framework. Manual calls to makeDefault() are only needed for advanced dialog interactions where default focus behavior is changed dynamically.
VARIABLES
The following global variables affect the visual rendering of TButton.
$shadows
Defines the characters used to draw the button shadow.
$markers
Defines the characters used as button markers, for example [].
CONSTRUCTOR
new
my $btn = TButton->new(
bounds => $bounds,
title => $title,
command => $command,
flags => $flags
);
Creates a new button control.
- bounds
-
The rectangular region defining the button's position (TRect).
- title
-
The caption displayed on the button, usually containing a hotkey marker (Str).
- command
-
The command identifier broadcast when the button is pressed (PositiveOrZeroInt).
- flags
-
Behavioral flags controlling default state, focus handling, and selection (bfXXXX).
new_TButton
my $btn = new_TButton($bounds, $title, $command, $flags);
Factory-style constructor using positional arguments.
ATTRIBUTES
The following attributes are exposed as read-only accessors.
- title
-
The caption displayed on the button (Str).
- command
-
The command identifier triggered when the button is pressed (PositiveOrZeroInt).
- flags
-
Bit-mask of behavioral settings such as default, broadcast, or selectable (PositiveOrZeroInt).
- amDefault
-
Boolean flag indicating whether the button is currently treated as the dialog's default button (Bool).
METHODS
draw
$btn->draw();
Renders the button according to its current state.
drawState
$btn->drawState($down);
Draws the button in pressed or unpressed visual form.
getPalette
my $palette = $btn->getPalette();
Returns the drawing palette for the button control.
handleEvent
$btn->handleEvent($event);
Processes mouse clicks, key presses, and broadcast events for the button.
makeDefault
$btn->makeDefault($enable);
Marks or unmarks the button as the dialog's default action button.
press
$btn->press();
Sends the button's command to the dialog owner.
setState
$btn->setState($state, $enable);
Updates the control's internal state and refreshes its appearance.
SEE ALSO
TUI::Dialogs::Dialog, TUI::Dialogs::Label, TUI::Views::View
AUTHORS
- Borland International (original Turbo Vision design)
- J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)
CONTRIBUTORS
COPYRIGHT AND LICENSE
Copyright (c) 1990-1994, 1997 by Borland International
Copyright (c) 1995, 2026 the "AUTHORS" and "CONTRIBUTORS" as listed above.
This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).