Curses::UI::Menubar - Create and manipulate menubar widgets
Curses::UI::Widget | +----Curses::UI::Container | +----Curses::UI::Window | +----Curses::UI::Menubar
use Curses::UI; my $cui = new Curses::UI;
# define the menu datastructure. my $menu_data = [....];
my $menu = $cui->add( 'menu', 'Menubar', -menu => $menu_data );
$menu->focus();
------------------------------------- menu1 | menu2 | menu3 | .... ------------------------------------- +-------------+ |menuitem 1 | |menuitem 2 |+--------------+ |menuitem 3 >>||submenuitem 1 | |menuitem 4 ||submenuitem 2 | +-------------+|submenuitem 3 | |submenuitem 4 | |submenuitem 5 | +--------------+
See exampes/demo-Curses::UI::Menubar in the distribution for a short demo.
my $menu1 = [ { -label => 'option 1', -value => '1-1' }, { -label => 'option 2', -value => '1-2' }, { -label => 'option 3', -value => '1-3' }, ];
my $menu2 = [ { -label => 'option 1', -value => \&sel1 }, { -label => 'option 2', -value => \&sel2 }, { -label => 'option 3', -value => \&sel3 }, ];
my $submenu = [ { -label => 'suboption 1', -value => '3-3-1' }, { -label => 'suboption 2', -callback=> \&do_it }, ];
my $menu3 = [ { -label => 'option 1', -value => \&sel2 }, { -label => 'option 2', -value => \&sel3 }, { -label => 'submenu 1', -submenu => $submenu }, ];
my $menu = [ { -label => 'menu 1', -submenu => $menu1 }, { -label => 'menu 2', -submenu => $menu2 } { -label => 'menu 3', -submenu => $menu3 } ];
* the value 'CURSOR_LEFT'
Call the 'cursor-left' routine and after that call the 'pulldown' routine. So this will open the menulistbox for the previous menu.
* the value 'CURSOR_RIGHT'
Call the 'cursor-right' routine and after that call the 'pulldown' routine. So this will open the menulistbox for the next menu.
* the value 'LOOSE_FOCUS'
The menubar will keep the focus, but no menulistbox will be open.
* the value 'ESCAPE'
The menubar will loose its focus and return the value 'ESCAPE' to the calling routine.
* A CODE reference
The code will be excuted, the menubar will loose its focus and the returnvalue of the CODE will be returned to the calling routine.
* Any other value
The menubar will loose its focus and the value will be returned to the calling routine.
Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
This package is free software and is provided ``as is'' without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |