Curses:...opupmenu(3)
Curses:...opupmenu(3) β straight outta the User Contributed Perl Documentation, and your bestie is here to walk you through it π
πΈ NAME πΈ
Curses::UI::Popupmenu β create and manipulate popupbox widgets. That's the whole name-and-game, bestie β¨
π¦ CLASS HIERARCHY π¦
Curses::UI::Widget
|
+----Curses::UI::Popupmenu
β¨ SYNOPSIS β¨
use Curses::UI;
my $cui = new Curses::UI;
my $win = $cui->add('window_id', 'Window');
my $popupbox = $win->add(
'mypopupbox', 'Popupmenu',
-values => [1, 2, 3],
-labels => { 1 => 'One',
2 => 'Two',
3 => 'Three' },
);
$popupbox->focus();
my $value = $popupbox->get();
πΈ DESCRIPTION πΈ
Curses::UI::Popupmenu is a widget that can be used to create something very similar to a basic Curses::UI::Listbox. The difference is that the widget will show only the currently selected value (or "-------" if no value is yet selected). The list of possible values will be shown as a separate popup window if requested.
Normally the widget will look something like this:
[Current value ]
If the popup window is opened, it looks something like this:
[Current value ]
+--------------+
|Other value |
|Current value |
|Third value |
+--------------+
π STANDARD OPTIONS π
Every one of these is a standard option, and the explanation lives in Curses::UI::Widget:
-parentβ standard option; seeCurses::UI::Widget.-xβ standard option; seeCurses::UI::Widget.-yβ standard option; seeCurses::UI::Widget.-widthβ standard option; seeCurses::UI::Widget.-heightβ standard option; seeCurses::UI::Widget.-padβ standard option; seeCurses::UI::Widget.-padleftβ standard option; seeCurses::UI::Widget.-padrightβ standard option; seeCurses::UI::Widget.-padtopβ standard option; seeCurses::UI::Widget.-padbottomβ standard option; seeCurses::UI::Widget.-ipadβ standard option; seeCurses::UI::Widget.-ipadleftβ standard option; seeCurses::UI::Widget.-ipadrightβ standard option; seeCurses::UI::Widget.-ipadtopβ standard option; seeCurses::UI::Widget.-ipadbottomβ standard option; seeCurses::UI::Widget.-titleβ standard option; seeCurses::UI::Widget.-titlefullwidthβ standard option; seeCurses::UI::Widget.-titlereverseβ standard option; seeCurses::UI::Widget.-onfocusβ standard option; seeCurses::UI::Widget.-onblurβ standard option; seeCurses::UI::Widget.
For an explanation of these standard options, see Curses::UI::Widget.
π WIDGET-SPECIFIC OPTIONS π
The first four are exactly the same as the options for the Listbox widget. So for an explanation of these, take a look at Curses::UI::Listbox.
-values < LIST >β same as theListboxoption, bestie; checkCurses::UI::Listboxfor the deets.-labels < HASHREF >β also exactly like theListboxoption, soCurses::UI::Listboxis your guide.-selected < INDEX >β sameListboxenergy; seeCurses::UI::Listbox.-wraparound < BOOLEAN >β yep, same asListbox; explanation is inCurses::UI::Listbox.-onchange < CODEREF >β sets the onChange event handler for the popupmenu widget. If a new item is selected, the code inCODEREFwill be executed. It will get the widget reference as its argument. Slay π
π METHODS π
These are standard methods. See Curses::UI::Widget for an explanation of these:
new ( OPTIONS )β standard method; seeCurses::UI::Widget.layout ( )β standard method; seeCurses::UI::Widget.draw ( BOOLEAN )β standard method; seeCurses::UI::Widget.intellidraw ( )β standard method; seeCurses::UI::Widget.focus ( )β standard method; seeCurses::UI::Widget.onFocus ( CODEREF )β standard method; seeCurses::UI::Widget.onBlur ( CODEREF )β standard method; seeCurses::UI::Widget.
And the ones with their own little spotlight:
get ( )β this method will return the currently selected value. Iconic.onChange ( CODEREF )β this method can be used to set the-onchangeevent handler (see above) after initialization of the popupmenu.
π DEFAULT BINDINGS π
There are bindings for the widget itself and bindings for the popup listbox that can be opened by this widget.
π§ The widget itself π§
<tab>β calls the'loose-focus'routine. This will have the widget loose its focus.<enter>, <cursor-right, <l>, <space>β calls the'open-popup'routine. This will show the popup listbox and bring the focus to this listbox. See The popup listbox below for a description of the bindings for this listbox.<cursor-down>, <j>β calls the'select-next'routine. This will select the item in the list that is after the currently selected item (unless the last item is already selected). If no item is selected, the first item in the list will get selected.<cursor-up>, <k>β calls the'select-prev'routine. This will select the item in the list that is before the currently selected item (unless the first item is already selected). If no item is selected, the first item in the list will get selected.
π The popup listbox π
The bindings for the popup listbox are the same as the bindings for the Listbox widget. So take a look at Curses::UI::Listbox for a description of these. The difference is that the 'loose-focus' and 'option-select' routine will have the popup listbox to close. If the routine 'option-select' is called, the active item will get selected.
π₯ SEE ALSO π₯
Go peek at: Curses::UI, Curses::UI::Listbox, Curses::UI::Widget, Curses::UI::Common.
π 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.
π And that's the page! Source/version: perl v5.42.2; date: 2023-07-03; and it's the Curses:...opupmenu(3) page. Bye bestie, go slay those popup menus! π
π¦ where this page comes from
- alpine 3.24: perl-curses-ui-doc 0.9609-r3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms