Tickit...Choice(3pm)

πŸ“¦ version 0.07, in alpine 3.24

πŸ’… Tickit...Choice(3pm) β€” the widget that lets your user pick a fave

okay so Tickit::Widget::Choice is literally a widget that gives you a choice from a list. that's the whole vibe. it's the group-chat poll of Tickit widgets, and honestly? iconic. πŸŽ€


✨ CONSTRUCTOR ✨

🌸 new

$choice = Tickit::Widget::Choice->new( %args )

this bad boy constructs a brand-new Tickit::Widget::Choice object. main character energy from the jump. ✨

it takes these named arguments, bestie:

  • choices => ARRAY β€” optional, no cap. if you pass it, it's gotta be an ARRAY reference full of two-element ARRAY references. each one gets added to the list of choices, just like if you'd called push_choice on every element in that array. 🫢
  • on_changed => CODE β€” optional too. if you supply it, it sets the initial value of the on_changed event handler. basically pre-loading your callback so it's ready to go. πŸ’–

πŸ¦‹ ACCESSORS πŸ¦‹

on_changed

$on_changed = $self->on_changed

set_on_changed

$self->set_on_changed( $on_changed )

these two return or set the CODE reference that gets called whenever the chosen selection changes. it's giving "text me when you change your mind" fr fr. 😭

$on_changed->( $choice, $value )

πŸ‘‘ METHODS πŸ‘‘

πŸ“ push_choice

$choice->push_choice( $value, $caption )

appends another choice to the list, with the value and the display caption you give it. one more option in the group chat. slay. πŸŽ€

πŸ’œ chosen_value

$value = $choice->chosen_value

returns the value of the currently-chosen choice. the winner. the one that ate. πŸ‘‘

🌈 choose_by_idx

$choice->choose_by_idx( $idx )

moves the chosen choice to the one at the given index. and listen β€” if this wasn't the previously-chosen one, it invokes the on_changed event. so don't be surprised when your callback fires. πŸ”₯

⭐ choose_by_value

$choice->choose_by_value( $value )

moves the chosen choise to the one having the given value β€” but only if such a choice actually exists, iykyk. if this wasn't the previously-chosen one, it invokes the on_changed event. same deal as above. ✨

$choice->popup_menu

displays the popup menu in a modal float and just... waits there until a choice is made. very "we're not leaving until everyone agrees" energy. πŸ’…


🌸 TODO 🌸

  • render a full border around the widget if height is at least 3. that's the whole item. we'll get to it. πŸ™ˆ

🫢 AUTHOR 🫢

Paul Evans <leonerd@leonerd.org.uk> β€” king behaviour, honestly. πŸ’–


lowkey a whole widget, highkey just vibes. go forth and let your users choose bestie. πŸŒˆπŸ’…

that's the page, babe β€” perl v5.42.2, dated 2026-02-15, straight from the Tickit...Choice(3pm) section of the User Contributed Perl Documentation. mwah. πŸ’œ

πŸ“¦ where this page comes from