1Curses::UI::Buttonbox(3U)ser Contributed Perl DocumentatiCounrses::UI::Buttonbox(3)
2
3
4

NAME

6       Curses::UI::Buttonbox - Create and manipulate button widgets
7

CLASS HIERARCHY

9        Curses::UI::Widget
10           |
11           +----Curses::UI::Buttonbox
12

SYNOPSIS

14           use Curses::UI;
15           my $cui = new Curses::UI;
16           my $win = $cui->add('window_id', 'Window');
17
18           my $buttons = $win->add(
19               'mybuttons', 'Buttonbox',
20               -buttons   => [
21                   {
22                     -label => '< Button 1 >',
23                     -value => 1,
24                     -shortcut => 1
25                   },{
26                     -label => '< Button 2 >',
27                     -value => 2,
28                     -shortcut => 2
29                   }
30               ]
31           );
32
33           $buttons->focus();
34           my $value = $buttons->get();
35

DESCRIPTION

37       Curses::UI::Buttonbox is a widget that can be used to create an array
38       of buttons (or, of course, only one button).
39

STANDARD OPTIONS

41       -parent, -x, -y, -width, -height, -pad, -padleft, -padright, -padtop,
42       -padbottom, -ipad, -ipadleft, -ipadright, -ipadtop, -ipadbottom,
43       -title, -titlefullwidth, -titlereverse, -onfocus, -onblur
44
45       For an explanation of these standard options, see Curses::UI::Widget.
46

WIDGET-SPECIFIC OPTIONS

48       ·   -buttons < ARRAYREF >
49
50           This option takes a reference to a list of buttons.  The list may
51           contain both predefined button types and complete button
52           definitions of your own.
53
54           * Your own button definition
55
56             A button definition is a reference to a hash. This
57             hash can have the following key-value pairs:
58
59             obligatory:
60             -----------
61
62             -label      This determines what text should be drawn
63                         on the button.
64
65             optional:
66             ---------
67
68             -value      This determines the returnvalue for the
69                         get() method. If the value is not defined,
70                         the get() method will return the index
71                         of the button.
72
73             -shortcut   The button will act as if it was pressed
74                         if the key defined by -shortcut is pressed
75
76             -onpress    If the value for -onpress is a CODE reference,
77                         this code will be executes if the button
78                         is pressed, before the buttons widget loses
79                         focus and returns.
80
81           * Predefined button type
82
83             This module has a predefined list of frequently used button
84             types. Using these in B<-buttons> makes things a lot
85             easier. The predefined button types are:
86
87             ok          -label    => '< OK >'
88                         -shortcut => 'o'
89                         -value    => 1
90                         -onpress  => undef
91
92             cancel      -label    => '< Cancel >'
93                         -shortcut => 'c'
94                         -value    => 0
95                         -onpress  => undef
96
97             yes         -label    => '< Yes >'
98                         -shortcut => 'y'
99                         -value    => 1
100                         -onpress  => undef
101
102             no          -label    => '< No >'
103                         -shortcut => 'n'
104                         -value    => 0
105                         -onpress  => undef
106
107           Example:
108
109             ....
110             -buttons => [
111                 { -label => '< My own button >',
112                   -value => 'mine!',
113                   -shortcut => 'm' },
114
115                 'ok',
116
117                 'cancel',
118
119                 { -label => '< My second button >',
120                   -value => 'another one',
121                   -shortcut => 's',
122                   -onpress => sub { die "Do not press this button!\n" } }
123             ]
124             ....
125
126       ·   -selected < INDEX >
127
128           By default the first button (index = 0) is active. If you want
129           another button to be active at creation time, add this option. The
130           INDEX is the index of the button you want to make active.
131
132       ·   -buttonalignment < VALUE >
133
134           You can specify how the buttons should be aligned in the widget.
135           Available values for VALUE are 'left', 'middle' and 'right'.
136
137       ·   -vertical < BOOLEAN >
138
139           When set to a true value, it will cause the buttons to be rendered
140           with vertical instead of horizontal alignment.
141

METHODS

143       ·   new ( OPTIONS )
144
145       ·   layout ( )
146
147       ·   draw ( BOOLEAN )
148
149       ·   focus ( )
150
151       ·   onFocus ( CODEREF )
152
153       ·   onBlur ( CODEREF )
154
155       ·   draw_if_visible ( )
156
157           These are standard methods. See Curses::UI::Widget for an
158           explanation of these.
159
160       ·   get ( )
161
162           This method will return the index of the currently active button.
163           If a value is given for that index (using the -value option, see
164           -buttons above), that value will be returned.
165

DEFAULT BINDINGS

167       ·   <enter>, <space>
168
169           TODO: Fix dox Call the 'loose-focus' routine. By default this
170           routine will have the container in which the widget is loose its
171           focus. If you do not like this behaviour, then you can have it
172           loose focus itself by calling:
173
174               $buttonswidget->set_routine('loose-focus', 'RETURN');
175
176           For an explanation of set_routine, see Curses::UI::Widget.
177
178       ·   <cursor left>, <h>
179
180           Call the 'previous' routine. This will make the previous button the
181           active button. If the active button already is the first button,
182           nothing will be done.
183
184       ·   <cursor right>, <l
185
186           Call the 'next' routine. This will make the next button the active
187           button. If the next button already is the last button, nothing will
188           be done.
189
190       ·   <any other key>
191
192           This will call the 'shortcut' routine. This routine will handle the
193           shortcuts that are set by the -shortcuts option.
194

SEE ALSO

196       Curses::UI, Curses::UI::Widget, Curses::UI::Common
197

AUTHOR

199       Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
200
201       Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
202
203       This package is free software and is provided "as is" without express
204       or implied warranty. It may be used, redistributed and/or modified
205       under the same terms as perl itself.
206
207
208
209perl v5.32.0                      2020-07-28          Curses::UI::Buttonbox(3)
Impressum