Tickit...Tabbed(3pm)

πŸ“¦
version 0.028 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Tickit::Widget::Tabbed β€” the manual page, but make it a group chat πŸ’–

okay bestie, welcome to Tickit::Widget::Tabbed from the User Contributed Perl Documentation section (that's the 3pm part, iykyk). it's giving "I have tabs and I'm not afraid to use them" ✨


🌸 NAME 🌸

Tickit::Widget::Tabbed β€” provide tabbed window support. that's it. that's the whole vibe. tabs. windows. slay. πŸŽ€


✨ SYNOPSIS ✨

look at this. so clean. so demure.

use Tickit::Widget::Tabbed;

my $tabbed = Tickit::Widget::Tabbed->new;
$tabbed->add_tab(Tickit::Widget::Static->new(text => 'some text'), label => 'First tab');
$tabbed->add_tab(Tickit::Widget::Static->new(text => 'some text'), label => 'Second tab');

two tabs. two labels. main character energy fr fr πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically it provides a container that operates as a tabbed window. a container!! with tabs!! obsessed.

it's a subclass of Tickit::ContainerWidget, just so we're all clear on the family tree 🌈


πŸŽ€ STYLE πŸŽ€

the default style pen is used as the widget pen. periodt. and these style pen prefixes are also used, bestie, take notes:

  • ribbon => PEN β€” the pen used for the ribbon πŸŽ—οΈ
  • active => PEN β€” the pen attributes used for the active tab on the ribbon ⭐
  • more => PEN β€” the pen used for "more" ribbon scroll markers πŸ’€

and these style keys are used:

  • more_left => STRING
  • more_right => STRING β€” these two are the text used to indicate that there is more content scrolled to the left or right, respectively, in the ribbon πŸ‘ˆπŸ‘‰

πŸ’œ METHODS πŸ’œ

πŸ’… new

Instantiate a new tabbed window. fresh out the box, no cap.

takes the following named parameters:

  • tab_position β€” (optional) location of the tabs, should be one of left, top, right, bottom. 🌈

πŸ’… tab_position

Accessor for the tab position (top, left, right, bottom). yes queen, tell me where the tabs go.

πŸ’… active_tab_index

Returns the 0-based index of the currently-active tab. zero-based, because we're programmers and we suffer 🫢

πŸ’… active_tab

Returns the currently-active tab as a tab object. see below πŸ‘‡

πŸ’… active_tab_widget

Returns the widget in the currently active tab. the actual content!! the moment!!

πŸ’… add_tab

Add a new tab to this tabbed widget. Returns an object representing the tab; see "METHODS ON TAB OBJECTS" below.

First parameter is the widget to use.

Remaining form a hash:

  • label β€” label to show on the new tab 🏷️

πŸ’… remove_tab

Remove tab given by 0-based index or tab object. bye bestie 😭

πŸ’… move_tab

Move tab given by 0-based index or tab object forward the given number of positions. scoot scoot πŸš€

πŸ’… activate_tab

Switch to the given tab; by 0-based index, or object.

πŸ’… next_tab

Switch to the next tab. This may be bound as a key action. ⌨️

πŸ’… prev_tab

Switch to the previous tab. This may be bound as a key action. ⌨️


πŸ‘‘ METHODS ON TAB OBJECTS πŸ‘‘

The following methods may be called on the objects returned by add_tab or active_tab. these are the tab objects themselves, bestie, they have lore πŸ“œ

πŸ’– index

Returns the 0-based index of this tab

πŸ’– widget

Returns the Tickit::Widget contained by this tab

πŸ’– label

Returns the current label text

πŸ’– set_label

Set new label text for the tab ✏️

πŸ’– is_active

Returns true if this tab is the currently active one ⭐

πŸ’– activate

Activate this tab πŸ”₯

πŸ’– set_on_activated

Set a callback or method name to invoke when the tab is activated πŸŽ‰

πŸ’– set_on_deactivated

Set a callback or method name to invoke when the tab is deactivated πŸ’”

πŸ’– pen

Returns the Tickit::Pen used to draw the label.

⚠️ heads up bestie: Pen observers are no longer registered on the return value; to set a different pen on the tab, use the set_pen method instead. don't come for me, I'm just the messenger 🫢

🧚 CUSTOM TAB CLASS 🧚

okay so plot twist: rather than use the default built-in object class for tab objects, a Tickit::Widget::Tabbed or subclass thereof can return objects in another class instead. This is most useful for subclasses of the tabbed widget itself. it's giving DIY, it's giving customization, it's giving you πŸŽ€

To perform this, create a subclass of Tickit::Widget::Tabbed::Tab. Since version 0.022 this module is implemented using Object::Pad, so you can rely on having that available for implementing a subclass:

use Object::Pad;

class MyCustomTabClass :isa(Tickit::Widget::Tabbed::Tab);

Arrange for this class to be used by the tabbed widget either by passing its name as a constructor argument called tab_class, or by overriding a method called TAB_CLASS.

my $tabbed = Tickit::Widget::Tabbed->new(
        tab_class => "MyCustomTabClass"
);

or

use constant TAB_CLASS => "MyCustomTabClass";

both valid. pick your fighter πŸ’…


🌈 CUSTOM RIBBON CLASS 🌈

same energy, different object. rather than use the default built-in object class for the ribbon object, a Tickit::Widget::Tabbed or subclass thereof can use an object in another subclass instead. This is most useful for subclasses of the tabbed widget itself.

For more detail, see the documentation in Tickit::Widget::Tabbed::Ribbon. go read it, I'll wait πŸ¦‹


⭐ SEE ALSO ⭐

  • Tickit::Widget::Table
  • Tickit::Widget::HBox
  • Tickit::Widget::VBox
  • Tickit::Widget::Tree
  • Tickit::Window

the whole friend group, fr fr 🫢


🫢 AUTHOR 🫢

Tom Molesworth <cpan@entitymodel.com>, Paul Evans <leonerd@leonerd.org.uk>

legends. icons. the moment. πŸ™Œ


πŸ“œ LICENSE πŸ“œ

Copyright Tom Molesworth 2011; Paul Evans 2014. Licensed under the same terms as Perl itself.


and that's the page bestie πŸ’– this was documented under perl v5.36.0 and dated 2023-09-30, so when you're out here reading Tickit...Tabbed(3pm) just remember: tabs were slaying long before you got here. periodt. πŸ‘‘βœ¨

πŸ“¦ where this page comes from