IUP/Controls/IupToggle

From Vendetta Lua
Jump to navigationJump to search


Controls

Dialog
Fill
Hbox
Vbox
Zbox
Cbox
Radio
Button
Canvas
Frame
Label
List
Multiline
Text
Toggle
Progress Bar
Matrix
Tree
Navmap

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{} -> (elem: ihandle)
This function returns the identifier of the created toggle, or nil 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.
IMCHECK: Image
IMCHECKINACTIVE: Image
VALUE: Toggle's state. Values can be "ON" or "OFF". Default: "OFF".
TITLE: Toggle's text.
SEGMENTED

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)
v: 1 if the toggle's state was shifted to on; 0 if it was shifted to off.
GETFOCUS_CB
KILLFOCUS_CB
ENTERWINDOW_CB
LEAVEWINDOW_CB

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.