Curses:...uttonbox(3)
๐ธ Curses:...uttonbox(3) ๐ธ
Hey bestie ๐ this is the Curses:...uttonbox(3) page from the User Contributed Perl Documentation. Itโs giving classic Perl-docs energy, but Iโm gonna walk you through it so it actually makes sense. Slay.
๐ NAME ๐
Curses::UI::Buttonbox โ create and manipulate button widgets ๐
๐ณ CLASS HIERARCHY ๐ณ
Curses::UI::Widget
|
+----Curses::UI::Buttonbox
โจ SYNOPSIS โจ
use Curses::UI;
my $cui = new Curses::UI;
my $win = $cui->add('window_id', 'Window');
my $buttons = $win->add(
'mybuttons', 'Buttonbox',
-buttons => [
{
-label => '< Button 1 >',
-value => 1,
-shortcut => 1
},{
-label => '< Button 2 >',
-value => 2,
-shortcut => 2
}
]
);
$buttons->focus();
my $value = $buttons->get();
๐ฆ DESCRIPTION ๐ฆ
Curses::UI::Buttonbox is a widget that can be used to create an array of buttons (or, of course, only one button). Iconic, honestly.
๐ STANDARD OPTIONS ๐
-parent, -x, -y, -width, -height, -pad, -padleft, -padright, -padtop, -padbottom, -ipad, -ipadleft, -ipadright, -ipadtop, -ipadbottom, -title, -titlefullwidth, -titlereverse, -onfocus, -onblur
For an explanation of these standard options, see Curses::UI::Widget.
๐ WIDGET-SPECIFIC OPTIONS ๐
-buttons < ARRAYREF >โ this option takes a reference to a list of buttons. The list may contain both predefined button types and complete button definitions of your own.
Your own button definition: a button definition is a reference to a hash. This hash can have the following key-value pairs:
- obligatory:
-labelโ this determines what text should be drawn on the button.
- optional:
-valueโ this determines the returnvalue for theget()method. If the value is not defined, theget()method will return the index of the button.-shortcutโ the button will act as if it was pressed if the key defined by-shortcutis pressed.-onpressโ if the value for-onpressis a CODE reference, this code will be executes if the button is pressed, before the buttons widget loses focus and returns.
Predefined button type: this module has a predefined list of frequently used button types. Using these in -buttons makes things a lot easier. The predefined button types are:
okโ-label => '< OK >',-shortcut => 'o',-value => 1,-onpress => undefcancelโ-label => '< Cancel >',-shortcut => 'c',-value => 0,-onpress => undefyesโ-label => '< Yes >',-shortcut => 'y',-value => 1,-onpress => undefnoโ-label => '< No >',-shortcut => 'n',-value => 0,-onpress => undef
Example:
....
-buttons => [
{ -label => '< My own button >',
-value => 'mine!',
-shortcut => 'm' },
'ok',
'cancel',
{ -label => '< My second button >',
-value => 'another one',
-shortcut => 's',
-onpress => sub { die "Do not press this button!\n" } }
]
....
-selected < INDEX >โ by default the first button (index = 0) is active. If you want another button to be active at creation time, add this option. The INDEX is the index of the button you want to make active.-buttonalignment < VALUE >โ you can specify how the buttons should be aligned in the widget. Available values for VALUE are'left','middle'and'right'.-vertical < BOOLEAN >โ when set to a true value, it will cause the buttons to be rendered with vertical instead of horizontal alignment.
๐ METHODS ๐
new ( OPTIONS )layout ( )draw ( BOOLEAN )focus ( )onFocus ( CODEREF )onBlur ( CODEREF )draw_if_visible ( )
These are standard methods. See Curses::UI::Widget for an explanation of these.
get ( )โ this method will return the index of the currently active button. If a value is given for that index (using the-valueoption, see-buttonsabove), that value will be returned.
๐ฎ DEFAULT BINDINGS ๐ฎ
<enter>,<space>โTODO: Fix doxCall the'loose-focus'routine. By default this routine will have the container in which the widget is loose its focus. If you do not like this behaviour, then you can have it loose focus itself by calling:
$buttonswidget->set_routine('loose-focus', 'RETURN');
For an explanation of set_routine, see Curses::UI::Widget.
<cursor left>,<h>โ call the'previous'routine. This will make the previous button the active button. If the active button already is the first button, nothing will be done.<cursor right>,<lโ call the'next'routine. This will make the next button the active button. If the next button already is the last button, nothing will be done.<any other key>โ this will call the'shortcut'routine. This routine will handle the shortcuts that are set by the-shortcutsoption.
๐ SEE ALSO ๐
Curses::UI, 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.
Okay bestie, thatโs the whole page ๐ This footer energy is perl v5.42.2, dated 2023-07-03, and the page is Curses:...uttonbox(3). Bye ๐
๐ฆ 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