NAME

Tickit::Widget::Button - a widget displaying a clickable button

SYNOPSIS

use Tickit;
use Tickit::Widget::Button;

my $tickit = Tickit->new;

my $button = Tickit::Widget::Button->new(
   label => "Click Me!",
   on_click => sub {
      my ( $self ) = @_;

      # Do something!
   },
);

$tickit->set_root_widget( $button );

$tickit->run;

DESCRIPTION

This class provides a widget which displays a clickable area with a label. When the area is clicked, a callback is invoked.

CONSTRUCTOR

$entry = Tickit::Widget::Button->new( %args )

Constructs a new Tickit::Widget::Button object.

Takes the following named arguments:

label => STR

Text to display in the button area

on_click => CODE

Optional. Callback function to invoke when the button is clicked.

ACCESSORS

$label = $button->label

$button->set_label( $label )

Return or set the text to display in the button area.

$on_click = $button->on_click

$button->set_on_click( $on_click )

Return or set the CODE reference to be called when the button area is clicked.

$on_click->( $button )

$align = $button->align

$button->set_align( $align )

$valign = $button->valign

$button->set_valign( $valign )

Accessors for the horizontal and vertical alignment of the label text within the button area. See also Tickit::WidgetRole::Alignable.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>