The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Fl::InputChoice - Combination of the Input Widget and a Menu Button

Description

The Fl::InputChoice is a combination of the input widget and a menu button.

The user can either type into the input area, or use the menu button chooser on the right to choose an item which loads the input area with the selected text.

The application can directly access both the internal Fl::Input and Fl::MenuButton widgets respectively using the input() and menubutton() accessor methods.

A full example of this widget can be found in eg/input_choice.pl

Methods

Fl::InputChoice inherits from Fl::Group and Fl::Widget. On top of that, it exposes the following methods...

new(...)

    my $ic_a = Fl::InputChoice->new(0, 0, 250, 500, 'Important Stuff');
    my $ic_b = Fl::InputChoice->new(0, 0, 250, 500);

The constructor creates a new widget using the given position, size, and label.

The destructor removes the widget.

add(...)

Add an item to the menu.

You can access the more complex <Fl::MenuButton-add()>> methods (setting callbacks, userdata, etc.) via menubutton().

Example:

    my $choice = Fl::InputChoice->new(100,10,120,25,"Fonts");
    my $mb = $choice->menubutton(); # use Fl::InputChoice's Fl::MenuButton
    $mb->add("Helvetica", 0, \&MyFont_CB); # use Fl::MenuButton's add() methods
    $mb->add("Courier",   0, \&MyFont_CB);
    $mb->add("More..",    0, \&FontDialog_CB);

changed(...)

    my $changed = $ic_a->changed();

Returns the combined changed() state of the input and menu button widget.

clear(...)

    $ic_a->clear( );

Removes all items from the menu.

clear_changed(...)

    $ic_a->clear_changed( );

Clears the changed() state of both input and menu button widgets.

input(...)

    my $input = $ic_a->input( );

Returns a pointer to the internal Fl::Input widget.

This can be used to directly access all of the Fl::Input widget's methods.

    my $mn_item = $ic_a->menu( );
    $ic_b->menu( $mn_item );

Gets or sets the Fl_Menu_Item array used for the menu.

    my $mn_btn = $ic_a->menubutton( );

Returns a pointer to the internal Fl::MenuButton widget.

This can be used to access any of the methods of the menu button, e.g.

    my $choice = Fl::InputChoice->(100, 10, 120, 25, "Choice:");
    ...
    # Print all the items in the choice menu
    for ( my $t = 0; $t < $choice->menubutton()->size(); $t++ ) {
        my $item = $choice->menubutton->menu->[$t];
        printf("item %d -- label=%s\n", $t, $item->label ? $item->label : '(Null)');
    }

resize( ... )

    $ic_a->menubutton( int x, int y, int w, int h );

Resizes the Fl::Group widget and all of its children.

The Fl::Group widget first resizes itself, and then it moves and resizes all its children according to the rules documented for <Fl::Group-resizable($widget)>>.

set_changed( )

    $ic_a->set_changed( );

Sets the changed() state of both input and menu button widgets to the specfied value.

value( ... )

    $ic_a->value( 1 );
    $ic_b->value( "One" );

Sets the Fl::Input text field's contents.

If this is a string, it does not affect the menu selection.

If this is an integer, item number $index is chosen in the menu and the Fl::Input text field is set to that value. Any previous text is cleared.

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Sanko Robinson <sanko@cpan.org>