07 Jul 2022 12:01:39 UTC
- Distribution: Tickit-Widgets
- Module version: 0.35
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (12)
- Testers (12 / 0 / 18)
- KwaliteeBus factor: 1
- % Coverage
- License: perl_5
- Perl: v5.20.0
- Download (89.57KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:1 non-PAUSE user
Tickit::Widget::RadioButton- a widget allowing a selection from multiple options
use Tickit; use Tickit::Widget::RadioButton; use Tickit::Widget::VBox; my $group = Tickit::Widget::RadioButton::Group->new; my $vbox = Tickit::Widget::VBox->new; $vbox->add( Tickit::Widget::RadioButton->new( caption => "Radio button $_", group => $group, ) ) for 1 .. 5; Tickit->new( root => $vbox )->run;
This class provides a widget which allows a selection of one value from a group of related options. It provides a clickable area and a visual indication of which button in the group is the one currently active. Selecting a new button within a group will unselect the previously-selected one.
This widget is part of an experiment in evolving the design of the Tickit::Style widget integration code, and such is subject to change of details.
The default style pen is used as the widget pen. The following style pen prefixes are also used:
The following style keys are used:
- tick => STRING
The text used to indicate the active button
- spacing => INT
Number of columns of spacing between the tick mark and the caption text
The following style tags are used:
The following style actions are used:
The main action to activate the
$radiobutton = Tickit::Widget::RadioButton->new( %args )
Constructs a new
Takes the following named argmuents
- label => STRING
The label text to display alongside this button.
- group => Tickit::Widget::RadioButton::Group
Optional. If supplied, the group that the button should belong to. If not supplied, a new group will be constructed that can be accessed using the
- value => SCALAR
Optional. If supplied, used to set the button's identification value, which is passed to the group's
$group = $radiobutton->group
Tickit::Widget::RadioButton::Groupthis button belongs to.
$label = $radiobutton->label $radiobutton->set_label( $label )
Returns or sets the label text of the button.
$on_toggle = $radiobutton->on_toggle
$radiobutton->set_on_toggle( $on_toggle )
Return or set the CODE reference to be called when the button state is changed.
$on_toggle->( $radiobutton, $active )
When the radio tick mark moves from one button to another, the old button is marked unactive before the new one is marked active.
$value = $radiobutton->value
$radiobutton->set_value( $value )
Return or set the scalar value used to identify the radio button to the group's
on_changedcallback. This can be any scalar value; it is simply stored by the button and not otherwise used.
Sets this button as the active member of the group, deactivating the previous one.
$active = $radiobutton->is_active
Returns true if this button is the active button of the group.
Tickit::Widget::RadioButtonbelongs to a group. Only one button can be active in a group at any one time. The
groupaccessor returns the group the button is a member of. The following methods are available on it.
A group can be explicitly created to pass to a button's constructor, or one will be implicitly created for a button if none is passed.
$group = Tickit::Widget::RadioButton::Group->new
Returns a new group.
$radiobutton = $group->active
Returns the button which is currently active in the group
$on_changed = $group->on_changed
$group->set_on_changed( $on_changed )
Return or set the CODE reference to be called when the active member of the group changes. This may be more convenient than setting the
on_togglecallback of each button in the group.
The callback is passed the currently-active button, and its
$on_changed->( $active, $value )
Paul Evans <email@example.com>
Module Install Instructions
To install Tickit::Widgets, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Tickit::Widgets
For more information on module installation, please visit the detailed CPAN module installation guide.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|