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.

Parameters/Return

Ihandle* IupToggle(char *title, char *action); [in C]
iuptoggle{title = title: string} -> (elem: iuplua_tag) [in IupLua3]
iup.toggle{title = title: string} -> (elem: iuplua_tag) [in IupLua5]
toggle(title, action) [in LED]

title: Text to be shown on the toggle.
action: name of the action generated when the toggle is selected.

This function returns the identifier of the created toggle, 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. 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 of the pressed toggle.

IMINACTIVE: Image 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".

SIZE: Toggle size.

TITLE: Toggle's text.

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 IupLua]

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

Notes

Toggles with images or texts 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.

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

In Windows, for toggles inside a radio the ACTION callback may also be called when a not selected toggle receive the focus.

Examples

See Also

IupImage, IupButton, IupLabel.