---
name: "Tickit::Widget::Tabbed::Ribbon"
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::Ribbon"
---

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

base class for "Tickit::Widget::Tabbed" control ribbon

## NAME

"Tickit::Widget::Tabbed::Ribbon" - base class for "Tickit::Widget::Tabbed" control ribbon

## DESCRIPTION

This class contains the default implementation for the control ribbon used by Tickit::Widget::Tabbed, and also acts as a base class to assist in the creation of a custom ribbon. Details of this class and its operation are useful to know when implenting a custom control ribbon.

It is not necessary to consider this class if simply using the `"Tickit::Widget::Tabbed"` with its default control ribbon.

## CUSTOM RIBBON CLASS

To create a custom ribbon class, create a subclass of `"Tickit::Widget::Tabbed::Ribbon"` with a constructor having the following behaviour:

```
 use Object::Pad;
 class Custom::Ribbon::Class :isa(Tickit::Widget::Tabbed::Ribbon);
 sub new_for_orientation   # note: Not a method
 {
         my $class = shift;
         my ( $orientation, %args ) = @_;
         ...
  }
```

Alternatively if this is not done, then one of two subclasses will be used for the constructor, by appending `"::horizontal"` or `"::vertical"` to the class name. In this case, the custom class should provide these as well.

```
 use Object::Pad;
 class Custom::Ribbon::Class
        :isa(Tickit::Widget::Tabbed::Ribbon);
 class Custom::Ribbon::Class::horizontal
        :isa(Custom::Ribbon::Class);
 ...
 class Custom::Ribbon::Class::vertical
        :isa(Custom::Ribbon::Class);
 ...
```

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

```
 my $tabbed = Tickit::Widget::Tabbed->new(
         ribbon_class => "Ribbon::Class::Name"
 );
```

or

```
 use constant RIBBON_CLASS => "Ribbon::Class::Name";
```

## METHODS

### tabs

```
 @tabs = $ribbon->tabs
 $count = $ribbon->tabs
```

Returns a list of the contained Tickit::Widget::Tabbed tab objects in list context, or the count of them in scalar context.

### active\_tab\_index

```
 $index = $ribbon->active_tab_index
```

Returns the index of the currently-active tab

### active\_tab

```
 $tab = $ribbon->active_tab
```

Returns the currently-active tab as a `"Tickit::Widget::Tabbed"` tab object.

## SUBCLASS METHODS

The subclass will need to provide implementations of the following methods.

### render

```
 $ribbon->render( %args )
```

### lines

```
 $lines = $ribbon->lines
```

### cols

```
 $cols = $ribbon->cols
```

As per the Tickit::Widget methods.

### on\_key

```
 $handled = $ribbon->on_key( $ev )
```

### on\_mouse

```
 $handled = $ribbon->on_mouse( $ev )
```

As per the Tickit::Widget methods. Optional. If not supplied then the ribbon will not respond to keyboard or mouse events.

### scroll\_to\_visible

```
 $ribbon->scroll_to_visible( $index )
```

Requests that a scrollable control ribbon scrolls itself so that the given `$index` tab is visible.

## AUTHOR

Paul Evans \<leonerd@leonerd.org.uk\>
