IUP/Controls/IupToggle

From Vendetta Lua
Revision as of 23:27, 9 May 2023 by Draugath (Talk | contribs) (Created page with "__NOTOC__ __NOEDITSECTION__ 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 a...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


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

iup.toggle{title = title: string} -> (elem: ihandle)
title: Text to be shown on the toggle.
This function returns the identifier of the created toggle, or NULL if an error occurs.

Attributes

BGCOLOR: Color of the toggle.
FGCOLOR: Color of the text shown on the toggle.
FONT: Font size 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".
TITLE: Toggle's text.

Callbacks

ACTION: Action generated when the toggle's state (on/off) changes. The callback also receives the toggle's state.
elem:action(v: number) -> (ret: number) [in Iu
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.

See Also

IupImage, IupButton, IupLabel, IupRadio.