IupGLToggle (since 3.11)

Creates an embedded OpenGL 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 and/or an image. It inherits from IupGLButton. It exists only inside an IupGLCanvasBox.


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

title: Text to be shown on the toggle. It can be NULL. It will set the TITLE attribute.

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


The IupGLToggle element handle all attributes defined for the IupGLButton control, and consequently for the IupGLLabel control and for the IupGLSubCanvas control too.

CHECKMARK (non inheritable): Enables the check mark. Default: NO. When enabled the border and the background are not drawn, and a check mark box is drawn at left or right, according to RIGHTBUTTON.

CHECKMARKWIDTH (non inheritable): Size of the check mark. Default: 14.

RADIO (read-only): returns if the toggle is inside a radio. Can be "YES" or "NO". Valid only after the element is mapped, before returns NULL.

IGNORERADIO (non inheritable): when set the toggle will not behave as a radio when inside an IupRadio hierarchy. (since 3.21)

RIGHTBUTTON (non inheritable): place the check button at the right of the text. Can be "YES" or "NO". Default: "NO".

VALUE (non inheritable): Toggle's state. Values can be "ON", "OFF" or "TOGGLE". Default: "OFF". The TOGGLE option will invert the current state.


The IupGLToggle element handle all callbacks defined for the IupGLSubCanvas control.

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

int function(Ihandle* ih, int state); [in C]
elem:action(state: number) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
state: 1 if the toggle's state was set to on; 0 if it was set to off.

Returns: IUP_CLOSE will be processed.

VALUECHANGED_CB: Called after the value was interactively changed by the user. Called after the ACTION callback, but under the same context.

int function(Ihandle *ih); [in C]
elem:valuechanged_cb() -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.


IupGLToggle visual is the same as a IupGLButton. There is no check mark.

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.

A toggle that is a child of an IupRadio automatically receives a name when its is mapped into the native system. (since 3.16)

See Also

IupImage, IupGLButton, IupGLLabel, IupRadio.