| 1 | # You may distribute under the terms of either the GNU General Public License | ||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||
| 3 | # | ||
| 4 | # (C) Paul Evans, 2012-2022 -- leonerd@leonerd.org.uk | ||
| 5 | |||
| 6 | 1 | ▶ | use v5.26; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Object::Pad 0.73 ':experimental(init_expr)'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | package Tickit::Widget::Menu::Item 0.16; | ||
| 10 | class Tickit::Widget::Menu::Item | ||
| 11 | :strict(params) | ||
| 12 | 1 | ▶ | :does(Tickit::Widget::Menu::itembase); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 0 | ▶ | use Tickit::Utils qw( textwidth ); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 15 | |||
| 16 | =head1 NAME | ||
| 17 | |||
| 18 | C<Tickit::Widget::MenuItem> - an item to display in a C<Tickit::Widget::Menu> | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | Objects in this class are displayed in menus. Each item has a name and a | ||
| 23 | callback to invoke when the menu option is clicked on. | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | =head1 CONSTRUCTOR | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | =head2 new | ||
| 32 | |||
| 33 | $item = Tickit::Widget::Menu::Item->new( %args ) | ||
| 34 | |||
| 35 | Constructs a new C<Tickit::Widget::Menu::Item> object. | ||
| 36 | |||
| 37 | Takes the following named arguments: | ||
| 38 | |||
| 39 | =over 8 | ||
| 40 | |||
| 41 | =item name => STRING | ||
| 42 | |||
| 43 | Gives the name of the menu item. | ||
| 44 | |||
| 45 | =item on_activate => CODE | ||
| 46 | |||
| 47 | Callback to invoke when the menu item is clicked on. | ||
| 48 | |||
| 49 | =back | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | field $_on_activate :param = undef; | ||
| 54 | |||
| 55 | method activate () | ||
| 56 | { | ||
| 57 | $_on_activate->( $self ) if $_on_activate; | ||
| 58 | } | ||
| 59 | |||
| 60 | =head1 AUTHOR | ||
| 61 | |||
| 62 | Paul Evans <leonerd@leonerd.org.uk> | ||
| 63 | |||
| 64 | =cut | ||
| 65 | |||
| 66 | 0x55AA; | ||