Class Button

(back to index)

A pushable widget.

Inherits from Widget

Subclasses: Check_Button  Light_Button  Repeat_Button  Return_Button  Round_Button  

Property index


Function index



Button widgets generate callbacks when they are clicked by the user. You control exactly when and how by changing the values for type and when. By default, they are momentary, and only remain pressed while the user holds the mouse button down, but changing the type property allows toggle and radio button behavior.

Buttons can also generate callbacks in response to Event.shortcut events. The button can either have an explicit shortcut value or a letter shortcut can be indicated in the label with an '&' character before it. For the label shortcut it does not matter if Alt is held down, but 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 Event.keyboard event.

Subclasses have different appearance or behavior.

Detailed reference

value: boolean

value is true if this button is currently pressed.

Note that setting this property on a radio button will not unpress other buttons in the Group; you should call setonly() to activate radio buttons.

type: Buttontype

Buttons are normally pressed while the user holds down the mouse button. By setting type to Buttontype.toggle, each click will toggle the pressed state of the button. Setting type to selects radio button behavior; at most one radio button in a Group will be pressed; clicking on an inactive button will press it and unpress all the others.

setonly(): void

At most one of a set of radio buttons should be pressed at any given time. Calling setonly() presses the current button and ensures that all other buttons in the group are unpressed.

shortcut: Modified_Key

When the user types the shortcut key for a button, the button is activated. shortcut is an integer consisting of an ASCII character or extended keycode, with modifiers. strbyte('a')+Modifier.ctrl is Ctrl-A; Key.insert+Modifier.shift is Shift-Insert. See Key and Modifier for more information.

down_box: Boxtype

Normally down_box is 0; FLTK chooses an appropriate way to draw the button when pressed. If you'd like to choose a different rendering, set down_box to a Boxtype such as Boxtype.engraved.

doctool generated at Sun Aug 12 22:23:17 2001