Buttons generate callbacks when they are clicked by the user. You control exactly when and how by changing the values for type() and when().
Buttons can also generate callbacks in response to FL_SHORTCUT events. If the label() has an '&' character then the next character is a shortcut. If that letter is typed the button will trigger. FL ignores case and does not care if shift or alt are held down. Normally, if you have an input field in the same window, the user will have to hold down the Alt key so that the input field does not eat the event first as an FL_KEYBOARD event. You can also require certain combinations of shift keys, match F keys or control keys, or avoid displaying the underscore, by setting the shortcut() string.
There are some subclasses which draw the button differently:
Fl_Button(int,int,int,int,const char * = 0);
The constructor, takes a position, size, and label.
uchar type() const;
void type(uchar);
FL_NORMAL_BUTTON
:FL_NORMAL_BUTTON
: The value is unchanged.
FL_TOGGLE_BUTTON
: The value is inverted.
FL_RADIO_BUTTON
: The value is set to 1, and all
other buttons in the current group with
type()==FL_RADIO_BUTTON
are set to zero.
There are some subclasses which directly set the type():
uchar when() const;
void when(uchar);
FL_WHEN_RELEASE
:0
: The callback is not done, instead changed() is
turned on.
FL_WHEN_RELEASE
: The callback is done after the user
successfully clicks the button, or when a shortcut is typed.
FL_WHEN_CHANGED
: The callback is done each time the
value() changes (when the user pushes and releases the button, and as
the mouse is dragged around in and out of the button).
char value() const;
int value(int);
int set();
int clear();
void setonly();
Fl_Boxtype down_box() const;
void down_box(Fl_Boxtype);
uchar down_color() const;
void down_color(uchar c);
const char *shortcut() const;
void shortcut(const char *);
This string lets you set exactly what key combinations are used for shortcuts. If it is not null, then the "&" character in the label() is used to underscore letters, but not to figure out what key to match. This string is not copied, so it must point at static storage.
The string consists of any number of repeats of the following, concatenated as a string constant, thus allowing a button to have several shortcuts: