NAME
LibUI::Button - Button to be Clicked by the User to Trigger an Action
SYNOPSIS
use LibUI ':all';
use LibUI::Window;
use LibUI::Button;
Init && die;
my $window = LibUI::Window->new( 'Hi', 320, 100, 0 );
$window->setMargined( 1 );
my $btn = LibUI::Button->new('Click me!');
$btn->onClicked(
sub {
$_[0]->setText( sprintf 'Clicked %d times', ++$_[1] );
},
my $i = 0
);
$window->setChild($btn);
$window->onClosing(
sub {
Quit();
return 1;
},
undef
);
$window->show;
Main();
DESCRIPTION
A LibUI::Button object represents a control that visually represents a button to be clicked by the user to trigger an action.
Functions
Not a lot here but... well, it's just a button.
new( ... )
my $btn = LibUI::Button->new( 'Click me!' );
Creates a new button.
onClicked( ... )
$btn->onClicked(
sub {
my ($ctrl, $data) = @_;
...;
}, undef);
Registers a callback for when the button is clicked.
Expected parameters include:
$callback
- CodeRef that should expect the following:$data
- user data to be passed to the callback
setText( ... )
$btn->setText( 'Scan' );
Sets the button label text.
text( )
my $txt = $btn->text;
Sets the button label text.
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Sanko Robinson <sanko@cpan.org>