NAME
LibUI::Slider - Control to Display and Modify Integer Values via a Draggable Slider
SYNOPSIS
use LibUI ':all';
use LibUI::VBox;
use LibUI::Window;
use LibUI::Slider;
Init && die;
my $window = LibUI::Window->new( 'Hi', 320, 100, 0 );
$window->setMargined( 1 );
my $box = LibUI::VBox->new();
my $slider = LibUI::Slider->new( 1, 100 );
$box->append( $slider, 0 );
$slider->onChanged( sub { warn 'Sliding to ' . shift->value }, undef );
$slider->onReleased( sub { warn 'Stopped at ' . shift->value }, undef );
$window->setChild($box);
$window->onClosing(
sub {
Quit();
return 1;
},
undef
);
$window->show;
Main();
DESCRIPTION
A LibUI::Slider object represents a control to display and modify integer values via a draggable slider.
Values are guaranteed to be within the specified range.
Sliders by default display a tool tip showing the current value when being dragged.
Sliders are horizontal only.
Functions
Not a lot here but... well, it's just a simple widget.
new( ... )
my $sld = LibUI::Slider->new( 1, 100 );
Creates a new slider.
Expected parameters include:
The initial slider value equals the $min
imum value.
In the current upstream implementation, $min
and $max
are swapped if $min
is greater than $max
. This may change in the future though.
hasToolTip( )
if( $sld->hasToolTip ) {
...;
}
Returns whether or not the slider has a tool tip.
setHasToolTip( ... )
$sld->setHasToolTip( 0 );
Sets whether or not the slider has a tool tip.
onChanged( ... )
$sld->onChanged(
sub {
my ($ctrl, $data) = @_;
warn $ctrl->value;
}, undef);
Registers a callback for when the slider value is changed by the user.
Expected parameters include:
$callback
- CodeRef that should expect the following:$data
- user data to be passed to the callback
Note: The callback is not triggered when calling setValue( ... )
.
onReleased( ... )
$sld->onReleased(
sub {
my ($ctrl, $data) = @_;
warn $ctrl->value;
}, undef);
Registers a callback for when the slider is released from dragging.
Expected parameters include:
$callback
- CodeRef that should expect the following:$data
- user data to be passed to the callback
setRange( ... )
$sld->setRange( 10, 20 );
Sets the slider range.
Expected parameters include:
setValue( ... )
$sld->setValue( 50 );
Sets the slider value.
value( ... )
warn $sld->value( );
Returns the slider value.
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>