Curses:...:Menubar(3)

πŸ’– NAME πŸ’–

okay so bestie, this is Curses::UI::Menubar β€” Create and manipulate menubar widgets. It lives in the User Contributed Perl Documentation section, and the manual name folded up here is Curses:...:Menubar(3). πŸ’…

🧬 CLASS HIERARCHY 🧬

here's the family tree, no cap:

Curses::UI::Widget
   |
   +----Curses::UI::Container
           |
           +----Curses::UI::Window
                   |
                   +----Curses::UI::Menubar

🌈 SYNOPSIS 🌈

           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();

πŸ’œ DESCRIPTION πŸ’œ

this class is how you add a menubar to Curses::UI, bestie. and it can contain a whole complete submenu hierarchy. it looks β€” remotely :-) β€” like this:

        -------------------------------------
        menu1 | menu2 | menu3 | ....
        -------------------------------------
              +-------------+
              |menuitem 1   |
              |menuitem 2   |+--------------+
              |menuitem 3 >>||submenuitem 1 |
              |menuitem 4   ||submenuitem 2 |
              +-------------+|submenuitem 3 |
                             |submenuitem 4 |
                             |submenuitem 5 |
                             +--------------+

for a short demo, peek at exampes/demo-Curses::UI::Menubar in the distribution. 🫢

✨ STANDARD OPTIONS ✨

this class does not use any of the standard options that are provided by Curses::UI::Widget. not a single one, bestie. πŸ’€

πŸŽ€ WIDGET-SPECIFIC OPTIONS πŸŽ€

there is only one option: -menu. the value for this option is an ARRAYREF. this ARRAYREF behaves exactly like the one that is described in Curses::UI::MenuListbox. the difference is that for the top-level menu, you will only use -submenu's. example data structure:

           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 }
           ];

🌸 METHODS 🌸

  • new ( OPTIONS ) β€” standard method energy.
  • layout ( ) β€” standard method energy.
  • draw ( BOOLEAN ) β€” standard method energy.
  • focus ( ) β€” standard method energy.

these are all standard methods. see Curses::UI::Widget for an explanation of these. πŸ’–

πŸ¦‹ DEFAULT BINDINGS πŸ¦‹

  • <escape> β€” calls the 'escape' routine. this makes the menubar lose its focus and return the value 'ESCAPE' to the calling routine.
  • <tab> β€” calls the 'return' routine. this makes the menubar lose its focus and return the value 'LOOSE_FOCUS' to the calling routine.
  • <cursor-down>, <j>, <enter> β€” calls the 'pulldown' routine. this opens the menulistbox for the current menu and gives that menulistbox the focus. what happens after the menulistbox loses its focus depends on its return value:
    • the value 'CURSOR_LEFT' β€” call the 'cursor-left' routine, and after that call the 'pulldown' routine. so this opens the menulistbox for the previous menu.
    • the value 'CURSOR_RIGHT' β€” call the 'cursor-right' routine, and after that call the 'pulldown' routine. so this opens the menulistbox for the next menu.
    • the value 'LOOSE_FOCUS' β€” the menubar keeps the focus, but no menulistbox will be open.
    • the value 'ESCAPE' β€” the menubar loses its focus and returns the value 'ESCAPE' to the calling routine.
    • a CODE reference β€” the code gets executed, the menubar loses its focus, and the return value of the CODE is returned to the calling routine.
    • any other value β€” the menubar loses its focus and the value is returned to the calling routine.
  • <cursor-left>, <h> β€” calls the 'cursor-left' routine. this selects the previous menu. if the first menu is already selected, the last menu will be selected.
  • <cursor-right>, <l> β€” calls the 'cursor-right' routine. this selects the next menu. if the last menu is already selected, the first menu will be selected.

πŸ”₯ SEE ALSO πŸ”₯

go look at Curses::UI, Curses::UI::MenuListbox, and Curses::UI::Listbox. iykyk. ✨

πŸ‘‘ AUTHOR πŸ‘‘

Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.

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.


okay that's the page, bestie 🫢 source/version: perl v5.42.2 Β· date: 2023-07-03 Β· manual: Curses:...:Menubar(3). bye! πŸ’–
πŸ“¦ where this page comes from