GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CURSES::UI::BUTTONBOX (3)

.ds Aq ’

NAME

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

CONTENTS

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).

STANDARD OPTIONS

<B>-parentB>, <B>-xB>, <B>-yB>, <B>-widthB>, <B>-heightB>, <B>-padB>, <B>-padleftB>, <B>-padrightB>, <B>-padtopB>, <B>-padbottomB>, <B>-ipadB>, <B>-ipadleftB>, <B>-ipadrightB>, <B>-ipadtopB>, <B>-ipadbottomB>, <B>-titleB>, <B>-titlefullwidthB>, <B>-titlereverseB>, <B>-onfocusB>, <B>-onblurB>

For an explanation of these standard options, see Curses::UI::Widget.

WIDGET-SPECIFIC OPTIONS

o <B>-buttonsB> < 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.

* <B>Your own button definitionB>



  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 the
              get() method. If the value is not defined,
              the get() method will return the index
              of the button.

  -shortcut   The button will act as if it was pressed
              if the key defined by -shortcut is pressed

  -onpress    If the value for -onpress is a CODE reference,
              this code will be executes if the button
              is pressed, before the buttons widget loses
              focus and returns.



* <B>Predefined button typeB>



  This module has a predefined list of frequently used button
  types. Using these in B<-buttons> makes things a lot
  easier. The predefined button types are:

  ok          -label    => < OK >
              -shortcut => o
              -value    => 1
              -onpress  => undef

  cancel      -label    => < Cancel >
              -shortcut => c
              -value    => 0
              -onpress  => undef

  yes         -label    => < Yes >
              -shortcut => y
              -value    => 1
              -onpress  => undef

  no          -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" } }
  ]
  ....



o <B>-selectedB> < 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.

o <B>-buttonalignmentB> < VALUE >

You can specify how the buttons should be aligned in the widget. Available values for VALUE are ’left’, ’middle’ and ’right’.

o <B>-verticalB> < BOOLEAN >

When set to a true value, it will cause the buttons to be rendered with vertical instead of horizontal alignment.

METHODS

o <B>newB> ( OPTIONS )
o <B>layoutB> ( )
o <B>drawB> ( BOOLEAN )
o <B>focusB> ( )
o <B>onFocusB> ( CODEREF )
o <B>onBlurB> ( CODEREF )
o <B>draw_if_visibleB> ( )

These are standard methods. See Curses::UI::Widget for an explanation of these.

o <B>getB> ( )

This method will return the index of the currently active button. If a value is given for that index (using the <B>-valueB> option, see <B>-buttonsB> above), that value will be returned.

DEFAULT BINDINGS

o <<B>enterB>>, <<B>spaceB>>

TODO: Fix dox Call 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 <B>set_routineB>, see Curses::UI::Widget.

o <<B>cursor leftB>>, <<B>hB>>

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.

o <<B>cursor rightB>>, <<B>lB>

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.

o <<B>any other keyB>>

This will call the ’shortcut’ routine. This routine will handle the shortcuts that are set by the <B>-shortcutsB> option.

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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CURSES::UI::BUTTONBOX (3) 2011-09-01

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.