Tickit...kButton(3pm)

πŸ’– Tickit::Widget::CheckButton β€” the manual, bestie edition πŸ’–

okay so this is Tickit::Widget::CheckButton, a lil Perl module from the user-contributed Perl docs. it's a widget. it does a toggle. it's giving "yes/no but make it ✨aesthetic✨". let's get into it πŸŽ€


✨ NAME ✨

Tickit::Widget::CheckButton β€” a widget allowing a toggle true/false option πŸ’…

like... it's a checkbox. a button. a check button. the vibes are immaculate and the answer is either yes or no, no in-between, periodt.


🌸 SYNOPSIS 🌸

use Tickit;
use Tickit::Widget::CheckButton;
use Tickit::Widget::VBox;

my $vbox = Tickit::Widget::VBox->new;
$vbox->add( Tickit::Widget::CheckButton->new(
      label => "Check button $_",
) ) for 1 .. 5;

Tickit->new( root => $vbox )->run;

not me making five check buttons in a for loop like it's nothing 😭 iconic behaviour honestly. 1 .. 5, five buttons, one vbox, and then you just run it. slay.


πŸ¦‹ DESCRIPTION πŸ¦‹

so this class gives you a widget that lets you pick true or false. that's it. that's the whole job. it shows you a clickable little indication of the status plus a caption, and when you click on either the status or the caption, the status flips. invert. toggle. uno reverse card πŸƒ

lowkey important: 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 specifics, bestie πŸ’€

πŸŽ€ STYLE πŸŽ€

the default style pen is used as the widget pen. and then there's more. the following style pen prefixes are also used:

  • check => PEN β€” the pen used to render the check marker βœ…

the following style keys are used:

  • check => STRING β€” the text used to indicate the active status
  • spacing => INT β€” number of columns of spacing between the check mark and the caption text

the following style tags are used:

  • :active β€” set when this button's status is true

the following style actions are used:

  • toggle β€” the main action to activate the on_click handler

so yeah. pens, keys, tags, actions. the full aesthetic toolkit 🧚


πŸ‘‘ CONSTRUCTOR πŸ‘‘

new

$checkbutton = Tickit::Widget::CheckButton->new( %args );

constructs a new Tickit::Widget::CheckButton object. fresh out the box, main character energy πŸ’–

takes the following named argmuents:

  • label => STRING β€” the label text to display alongside this button.
  • on_toggle => CODE β€” optional. callback function to invoke when the check state is changed.
(yes the original says "argmuents". we keep the typo. it's part of the lore now πŸ™ˆ)

πŸ’œ ACCESSORS πŸ’œ

label

set_label

$label = $checkbutton->label;

$checkbutton->set_label( $label );

returns or sets the label text of the button. get it, set it, live your truth ✨

on_toggle

$on_toggle = $checkbutton->on_toggle;

set_on_toggle

$checkbutton->set_on_toggle( $on_toggle );

return or set the CODE reference to be called when the button state is changed. and here's how it gets called:

$on_toggle->( $checkbutton, $active );

it hands you the button and the active state. two for one. obsessed 🫢


πŸ”₯ METHODS πŸ”₯

activate

$checkbutton->activate;

sets this button's active state to true. no cap.

deactivate

$checkbutton->deactivate;

sets this button's active state to false. rip.

is_active

$active = $checkbutton->is_active;

returns this button's active state. the vibe check, basically 🌈


🌟 AUTHOR 🌟

Paul Evans <leonerd@leonerd.org.uk> β€” the legend themselves πŸ‘‘


and that's the whole page, bestie! this one shipped as perl v5.40.0, dated 2024-09-16, from the Tickit...kButton(3pm) corner of the User Contributed Perl Documentation. go forth and toggle something, you absolute icon πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from