NAME

UI::Various::Optionmenu - general option-menu widget of UI::Various

SYNOPSIS

use UI::Various;
my $main = UI::Various::main();
my @options = (0, [1st => 1], [2nd => 2], [3rd => 3]);
$main->window(...
              UI::Various::Optionmenu->new(init => 2,
                                           options => \@options),
              ...);
$main->mainloop();

ABSTRACT

This module defines the general widget for a menu of options in an application using UI::Various.

DESCRIPTION

Besides the common attributes inherited from UI::Various::widget the Optionmenu widget knows the following additional attributes:

Attributes

options [rw, fixed]

a reference to a list of option pairs / options

The list of options must be either an ARRAY of pairs (reference to an ARRAY with two elements each) of menu entries with corresponding values or simple scalar values, which will be mapped into the aforementioned pairs.

init [wo]

option selected initially

The option selected initially must be specified by its value, not by the menu entry.

on_select [rw, optional]

an optional callback called after changing the selection

The callback routine is called with the selected value (not menu entry) as parameter.

Note that in Tk the callback is also called during initialisation.

METHODS

Besides the accessors (attributes) described above and by UI::Various::widget and the methods inherited from UI::Various::widget only the constructor is provided by the Optionmenu class itself:

new - constructor

see UI::Various::core::construct

selected - get current value of the menu of options

$selection = $optionmenu->selected();

description:

This method returns the value (not the menu entry) of the currently selected option (or undef in nothing has been selected or initialised).

returns:

selected value (or undef)

SEE ALSO

UI::Various

LICENSE

Copyright (C) Thomas Dorner.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See LICENSE file for more details.

AUTHOR

Thomas Dorner <dorner (at) cpan (dot) org>