Choice Class Reference

Inherits Menu.

Inherited by ComboBox.

List of all members.

Public Member Functions

int handle (int)
int handle (int, const Rectangle &)
 Choice (int, int, int, int, const char *=0)
void draw ()

Static Public Attributes

NamedStyledefault_style


Detailed Description

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

choice.gif

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 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 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 Input widget. All text input will have menus of possible replacements and completions. Not yet implemented, unfortunately.


Constructor & Destructor Documentation

Choice::Choice int  x,
int  y,
int  w,
int  h,
const char *  l = 0
 

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


Member Function Documentation

void Choice::draw void   )  [virtual]
 

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

Reimplemented from Group.


The documentation for this class was generated from the following files:
Sun Jan 7 00:55:17 2007. FLTK ©2006 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.