Tickit...oButton(3pm)
β¨ Tickit::Widget::RadioButton β¨
okay bestie, so this is a Perl manual page β it lives in the User Contributed Perl Documentation section (that's the 3pm bit, iykyk) and it's literally all about one lil widget. it's called Tickit::Widget::RadioButton and it's giving "pick one from a bunch of options" energy π
πΈ NAME πΈ
Tickit::Widget::RadioButton β a widget allowing a selection from multiple options π
π¦ SYNOPSIS π¦
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;
π DESCRIPTION π
so basically this class hands you a widget that lets you select one value out of a group of related options. classic radio button behavior, no cap. it gives you a clickable area plus a visual lil indication of which button in the group is the currently active one π
and the best part? when you select a new button within a group, the previously-selected one gets unselected automatically. the way it just... handles that for you. iconic. β¨
real talk though β this widget is part of an experiment in evolving the design of the Tickit::Style widget integration code, so the details are subject to change. don't get too attached to the specifics, bestie π
π STYLE π
the default style pen is used as the widget pen. also, these style pen prefixes get used:
tick=> PEN β the pen used to render the tick marker β
and these style keys:
tick=> STRING β the text used to indicate the active buttonspacing=> INT β number of columns of spacing between the tick mark and the caption text
these style tags:
:activeβ set when this button is the active one of the group π
and these style actions:
activateβ the main action to activate theon_clickhandler
π CONSTRUCTOR π
new
$radiobutton = Tickit::Widget::RadioButton->new( %args );
constructs a new Tickit::Widget::RadioButton object, slay π«Ά
it takes the following named arguments:
label=> STRING β the label text to display alongside this button.group=> Tickit::Widget::RadioButton::Group β optional. if you supply it, that's the group the button belongs to. if you don't supply it, a brand new group gets constructed, and you can grab it with thegroupaccessor.value=> SCALAR β optional. if supplied, it sets the button's identification value, which gets passed along to the group'son_changedcallback.
π§ ACCESSORS π§
group
$group = $radiobutton->group;
returns the Tickit::Widget::RadioButton::Group this button belongs to π
label
set_label
$label = $radiobutton->label;
$radiobutton->set_label( $label );
returns or sets the label text of the button. get it, set it, live ur truth β¨
on_toggle
$on_toggle = $radiobutton->on_toggle;
set_on_toggle
$radiobutton->set_on_toggle( $on_toggle );
return or set the CODE reference to be called when the button state changes.
$on_toggle->( $radiobutton, $active );
heads up: when the radio tick mark moves from one button to another, the old button is marked unactive before the new one is marked active. order matters, bestie π
value
$value = $radiobutton->value;
set_value
$radiobutton->set_value( $value );
return or set the scalar value used to identify the radio button to the group's on_changed callback. this can be any scalar value β the button literally just stores it and does nothing else with it. it's giving "not my job, I'm just holding it" π
π₯ METHODS π₯
activate
$radiobutton->activate;
sets this button as the active member of the group, and deactivates the previous one. main character moment, fr fr π
is_active
$active = $radiobutton->is_active;
returns true if this button is the active button of the group β
π GROUPS π
every Tickit::Widget::RadioButton belongs to a group. only one button can be active in a group at any one time β that's the whole vibe. the group accessor returns the group the button is a member of. and here's what you can do with it β¬οΈ
a group can be explicitly created and passed to a button's constructor, or one will be implicitly created for a button if you don't pass one. no pressure, it's got you π«Ά
new
$group = Tickit::Widget::RadioButton::Group->new;
returns a new group β¨
active
$radiobutton = $group->active;
returns the button which is currently active in the group π
on_changed
$on_changed = $group->on_changed;
set_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. ngl this may be way more convenient than setting the on_toggle callback of every single button in the group β imagine doing all that manually π
the callback gets passed the currently-active button, and its value:
$on_changed->( $active, $value );
πΈ AUTHOR πΈ
Paul Evans <leonerd@leonerd.org.uk> π
and that's the whole page, bestie!! no cap, you now know everything about Tickit::Widget::RadioButton π this absolute bop of a doc came from perl v5.40.0, dated 2024-09-16 β periodt π
β¨π¦
π¦ where this page comes from
- ubuntu resolute: libtickit-widgets-perl 0.42-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtickit-widgets-perl 0.42-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms