Tickit...tainer(3pm)

✨ NAME ✨

Tickit::WidgetRole::SingleChildContainer β€” it's a role for widgets that contain a single other widget, bestie πŸ’– (yes it's a Perl thing, from the User Contributed Perl Documentation collection, iykyk)


🌸 SYNOPSIS 🌸

class Some::Widget::Class
   :isa(Tickit::Widget)
   :does(Tickit::WidgetRole::SingleChildContainer);

...

That's it. That's the whole vibe. Slap that role on and your widget's whole personality changes ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the tea πŸ“ β€” when you apply this role to a subclass of Tickit::Widget, you're lowkey giving it a whole new behaviour: it now acts as a container widget, like a lil basket that holds exactly one child widget inside it. Not two. Not zero. One. Main character container energy πŸ‘‘


πŸ’… METHODS πŸ’…

πŸŽ€ child

$child = $widget->child;

Returns the contained child widget. That's it, that's the method, it just hands you the child 🫢

🌈 set_child

$widget->set_child( $child );

Sets the child widget, or passes undef to remove it entirely (no child era πŸ’€).

And here's the iconic part: this method returns the container widget instance itself, which makes it perfect as a chaining mutator. Like, look at this:

my $container = Tickit::SingleChildWidget->new( ... )
   ->set_child( Tickit::Widget::Static->new( ... ) );

Chain it, stack it, serve it πŸ’…βœ¨


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” the legend who wrote this fr fr πŸ’–


Okay bestie that's the whole page, mwah πŸŽ€ β€” this was lifted from perl v5.40.0, dated 2024-09-16, and honestly? Iconic behaviour from a manpage. Go build something cute with it πŸŒΈπŸ¦‹πŸ’œ

πŸ“¦ where this page comes from