Sanko Robinson > FLTK-0.532009 > FLTK::Choice



Annotate this POD


View/Report Bugs
Module Version: 0.532006   Source  


FLTK::Choice - Popup list of items that the user can choose one of

Description ^

Subclass of FLTK::Menu that provides a button that pops up the menu, and also displays the text of the most-recently selected menu item.

The appearance is designed to look like an "uneditable ComboBox" in Windows, but it is somewhat different in that it does not contain a text editor, also the menu pops up with the current item under the cursor, which is immensely easier to use once you get used to it. This is the same UI as the Macintosh and Motif, which called this an OptionButton.

The user can change the value by popping up the menu by clicking anywhere in the widget and moving the cursor to a different item, or by typing up and down arrow keys to cycle amoung the items. Typing the FLTK::Widget::shortcut() of any of the items will also change the value to that item.

If you set a shortcut() on this widget itself or put &x in the label, that shortcut will pop up the menu. The user can then use arrow keys or the mouse to change the selected item.

When the user changes the value() the callback is done.

If you wish to display text that is different than any of the menu items, you may instead want an FLTK::PopupMenu. It works identically but instead displays an empty box with the label() inside it, you can then change the label() as needed.

If you want a "real" ComboBox where the user edits the text, this is a planned addition to the FLTK::Input widget. All text input will have menus of possible replacements and completions. Not yet implemented, unfortunately.

Functions ^


my $style = $choice->default_style( );

Get the style

$choice->default_style( $style );

Set the style.


$choice->draw( );

You can change the icon drawn on the right edge by setting glyph() to your own function that draws whatever you want.


my $self = $choice->new( $x, $y, $w, $h, $label );

The constructor makes the menu empty. See Menu and StringList for information on how to set the menu to a list of items.

Author ^

Sanko Robinson <> -

License and Legal ^

Copyright (C) 2008-2010 by Sanko Robinson <>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.

syntax highlighting: