1Curses::UI::Menubar(3)User Contributed Perl DocumentationCurses::UI::Menubar(3)
2
3
4

NAME

6       Curses::UI::Menubar - Create and manipulate menubar widgets
7

CLASS HIERARCHY

9        Curses::UI::Widget
10           |
11           +----Curses::UI::Container
12                   |
13                   +----Curses::UI::Window
14                           |
15                           +----Curses::UI::Menubar
16

SYNOPSIS

18           use Curses::UI;
19           my $cui = new Curses::UI;
20
21           # define the menu datastructure.
22           my $menu_data = [....];
23
24           my $menu = $cui->add(
25               'menu', 'Menubar',
26               -menu => $menu_data
27           );
28
29           $menu->focus();
30

DESCRIPTION

32       This class can be used to add a menubar to Curses::UI. This menubar can
33       contain a complete submenu hierarchy. It looks (remotely :-) like this:
34
35        -------------------------------------
36        menu1 | menu2 | menu3 | ....
37        -------------------------------------
38              +-------------+
39              |menuitem 1   |
40              |menuitem 2   |+--------------+
41              |menuitem 3 >>||submenuitem 1 |
42              |menuitem 4   ||submenuitem 2 |
43              +-------------+|submenuitem 3 |
44                             |submenuitem 4 |
45                             |submenuitem 5 |
46                             +--------------+
47
48       See exampes/demo-Curses::UI::Menubar in the distribution for a short
49       demo.
50

STANDARD OPTIONS

52       This class does not use any of the standard options that are provided
53       by Curses::UI::Widget.
54

WIDGET-SPECIFIC OPTIONS

56       There is only one option: -menu. The value for this option is an
57       ARRAYREF. This ARRAYREF behaves exactly like the one that is described
58       in Curses::UI::MenuListbox.  The difference is that for the top-level
59       menu, you will only use -submenu's. Example data structure:
60
61           my $menu1 = [
62               { -label => 'option 1', -value => '1-1' },
63               { -label => 'option 2', -value => '1-2' },
64               { -label => 'option 3', -value => '1-3' },
65           ];
66
67           my $menu2 = [
68               { -label => 'option 1', -value => \&sel1 },
69               { -label => 'option 2', -value => \&sel2 },
70               { -label => 'option 3', -value => \&sel3 },
71           ];
72
73           my $submenu = [
74               { -label => 'suboption 1', -value => '3-3-1' },
75               { -label => 'suboption 2', -callback=> \&do_it },
76           ];
77
78           my $menu3 = [
79               { -label => 'option 1', -value => \&sel2 },
80               { -label => 'option 2', -value => \&sel3 },
81               { -label => 'submenu 1', -submenu => $submenu },
82           ];
83
84           my $menu = [
85               { -label => 'menu 1', -submenu => $menu1 },
86               { -label => 'menu 2', -submenu => $menu2 }
87               { -label => 'menu 3', -submenu => $menu3 }
88           ];
89

METHODS

91new ( OPTIONS )
92
93layout ( )
94
95draw ( BOOLEAN )
96
97focus ( )
98
99           These are standard methods. See Curses::UI::Widget for an
100           explanation of these.
101

DEFAULT BINDINGS

103       •   <escape>
104
105           Call the 'escape' routine. This will have the menubar loose its
106           focus and return the value 'ESCAPE' to the calling routine.
107
108       •   <tab>
109
110           Call the 'return' routine. This will have the menubar loose its
111           focus and return the value 'LOOSE_FOCUS' to the calling routine.
112
113       •   <cursor-down>, <j>, <enter>
114
115           Call the 'pulldown' routine. This will open the menulistbox for the
116           current menu and give that menulistbox the focus. What happens
117           after the menulistbox loses its focus, depends upon the returnvalue
118           of it:
119
120           * the value 'CURSOR_LEFT'
121
122             Call the 'cursor-left' routine and after that
123             call the 'pulldown' routine. So this will open
124             the menulistbox for the previous menu.
125
126           * the value 'CURSOR_RIGHT'
127
128             Call the 'cursor-right' routine and after that
129             call the 'pulldown' routine. So this will open
130             the menulistbox for the next menu.
131
132           * the value 'LOOSE_FOCUS'
133
134             The menubar will keep the focus, but no
135             menulistbox will be open.
136
137           * the value 'ESCAPE'
138
139             The menubar will loose its focus and return the
140             value 'ESCAPE' to the calling routine.
141
142           * A CODE reference
143
144             The code will be excuted, the menubar will loose its
145             focus and the returnvalue of the CODE will be
146             returned to the calling routine.
147
148           * Any other value
149
150             The menubar will loose its focus and the value will
151             be returned to the calling routine.
152
153       •   <cursor-left>, <h>
154
155           Call the 'cursor-left' routine. This will select the previous menu.
156           If the first menu is already selected, the last menu will be
157           selected.
158
159       •   <cursor-right>, <l>
160
161           Call the 'cursor-right' routine. This will select the next menu. If
162           the last menu is already selected, the first menu will be selected.
163

SEE ALSO

165       Curses::UI, Curses::UI::MenuListbox, Curses::UI::Listbox
166

AUTHOR

168       Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
169
170       Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
171
172       This package is free software and is provided "as is" without express
173       or implied warranty. It may be used, redistributed and/or modified
174       under the same terms as perl itself.
175
176
177
178perl v5.36.0                      2022-07-22            Curses::UI::Menubar(3)
Impressum