LibUI::Spinbox - Control to Display and Modify Integer Values via a Text Field or +/- Buttons
use LibUI ':all'; use LibUI::VBox; use LibUI::Window; use LibUI::Spinbox; Init( { Size => 1024 } ) && die; my $window = LibUI::Window->new( 'Hi', 320, 100, 0 ); my $box = LibUI::VBox->new(); my $count = LibUI::Spinbox->new( 1, 100 ); $box->append( $count, 0 ); $count->onChanged( sub { warn shift->value }, undef ); $window->setChild($box); $window->onClosing( sub { Quit(); return 1; }, undef ); $window->show; Main();
A LibUI::Spinbox object represents a control to display and modify integer values via a text field or +/- buttons.
This is a convenient control for having the user enter integer values. Values are guaranteed to be within the specified range.
The + button increases the held value by 1.
+
The - button decreased the held value by 1.
-
Entering a value out of range will clamp to the nearest value in range.
Not a lot here but... well, it's just a text box with some little buttons.
new( ... )
my $count = LibUI::Spinbox->new( 1, 100 );
Creates a new spinbox.
Expected parameters include:
$min
$max
The initial spinbox value equals the $minimum value.
In the current upstream implementation, $min and $max are swapped if $min is greater than $max. This may change in the future though.
onChanged( ... )
$count->onChanged( sub { my ($ctrl, $data) = @_; warn $ctrl->value; }, undef);
Registers a callback for when the spinbox value is changed by the user.
$callback
$count
$data
Note: The callback is not triggered when calling setValue( ... ).
setValue( ... )
$count->setValue( 50 );
Sets the spinbox value.
value( ... )
warn $count->value( );
Returns the spinbox value.
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Sanko Robinson <sanko@cpan.org>
To install LibUI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LibUI
CPAN shell
perl -MCPAN -e shell install LibUI
For more information on module installation, please visit the detailed CPAN module installation guide.