IupToggle

IUP - Portable User Interface

IupToggle

Creates the toggle interface element. It is a two-state (on/off) button that, when selected, generates an action that activates a function in the associated application. Its visual representation can contain a text or an image.

Creation

Ihandle* IupToggle(const char *title, const char *action); [in C]
iup.toggle{[title = title: string]} -> (elem: ihandle) [in Lua]
toggle(title, action) [in LED]

title: Text to be shown on the toggle. It can be NULL. It will set the TITLE attribute.
action: name of the action generated when the toggle is selected. It can be NULL.

Returns: the identifier of the created element, or NULL if an error occurs.

Attributes

BGCOLOR: Background color of the text shown on the toggle.

FGCOLOR: Color of the text shown on the toggle.

FONT: Character font of the text shown on the toggle.

IMAGE: Toggle image name. When the IMAGE attribute is defined, the TITLE is not shown. This makes the toggle look just like a button with an image, but its behavior remains the same.

IMPRESS: Image name of the pressed toggle.

IMINACTIVE: Image name of the inactive toggle. If it is not defined but IMAGE is defined then for inactive toggles the non transparent colors will be replaced by a darker version of the background color creating the disabled effect.

VALUE: Toggle's state. Values can be "ON" or "OFF". Default: "OFF". If 3STATE=YES then can also be "NOTDEF".

TITLE: Toggle's text.

3STATE: Enable a three state toggle. Valid for toggles with text only. Can be "YES" or NO". Default: "NO".

SELECTCOLOR: (Motif Only) Color of a selected toggle.

Callbacks

ACTION: Action generated when the toggle's state (on/off) changes. The callback also receives the toggle's state.

int funcion(Ihandle *self, int v); [in C]
elem:action(v: number) -> (ret: number) [in Lua]

v: 1 if the toggle's state was shifted to on; 0 if it was shifted to off.

Notes

Toggle with image or text can not change its behavior after mapped. This is a creation attribute. But after creation the image can be changed for another image, and the text for another text.

Text is left aligned and image is centered.

Toggles are activated using the Space key.

To build a set of mutual exclusive toggles, insert them in a IupRadio container. They must be inserted before creation, and their behavior can not be changed.

Unlike buttons, toggles always display the button border when IMAGE and IMPRESS are both defined.

In Windows, the BGCOLOR attribute is ignored when an IMAGE is specified.

In Windows XP if IMAGE is used and Visual Styles are enabled the focus feedback is not drawn.

Examples

Browse Example Files

See Also

IupImage, IupButton, IupLabel, IupRadio.