---
name: "Tickit::Widget::Tabbed"
section: "3pm"
platform: "linux"
package: "libtickit-widget-tabbed-perl"
version: "0.028-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Tickit::Widget::Tabbed"
---

# Tickit::Widget::Tabbed(3pm)

provide tabbed window support

## NAME

"Tickit::Widget::Tabbed" - provide tabbed window support

## SYNOPSIS

```
   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');
```

## DESCRIPTION

Provides a container that operates as a tabbed window.

Subclass of Tickit::ContainerWidget.

## STYLE

The default style pen is used as the widget pen. The following style pen prefixes are also used:

- 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

The following style keys are used:

- more\_left =\> STRING

  - more\_right =\> STRING

  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.

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).

### active\_tab\_index

Returns the 0-based index of the currently-active tab.

### active\_tab

Returns the currently-active tab as a tab object. See below.

### active\_tab\_widget

Returns the widget in the currently active tab.

### 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.

### move\_tab

Move tab given by 0-based index or tab object forward the given number of positions.

### 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"`.

### 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.

Pen observers are no longer registered on the return value; to set a different pen on the tab, use the `"set_pen"` method instead.

## CUSTOM TAB CLASS

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.

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";
```

## CUSTOM RIBBON CLASS

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.

## SEE ALSO

- •

  Tickit::Widget::Table

- •

  Tickit::Widget::HBox

- •

  Tickit::Widget::VBox

- •

  Tickit::Widget::Tree

- •

  Tickit::Window

## AUTHOR

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

## LICENSE

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