IupSetAttribute

IUP - Portable User Interface

IupSetAttribute

Defines an attribute for an interface element.

Parameters/Return

void IupSetAttribute(Ihandle *element, char *a, char *v); [in C]
IupSetAttribute(element: iulua_tag, attribute: string, value: string) [in IupLua3]
iup.SetAttribute(element: iulua_tag, attribute: string, value: string) [in IupLua5] 

element: Identifier of the interface element.
a: name of the attribute.
v: value of the attribute. If it equals NULL (nil in Lua), the attribute will be removed from the element.

Notes

The value stored in the attribute is not duplicated. Therefore, you can store your private attributes, such as a structure with data to be used in a callback.

When you want IUP to store an attribute by duplicating a string passed as a value, use function IupStoreAttribute.

For further information on memory allocation by IupSetAttribute, see IupGetAttribute’s notes section.

Example 1

Defines a radio’s initial value.

In C

Ihandle *portrait = IupToggle("Portrait" , "acao_portrait");
Ihandle *landscape = IupToggle("landscape" , "acao_landscape");
Ihandle *box = IupVbox(portrait, IupFill(),landscape, NULL);
Ihandle *modo = IupRadio(box);
IupSetHandle("landscape", landscape); /* associates a name to initialize the radio */
IupSetAttribute(modo, "VALUE", "landscape"); /* defines the radio’s initial value */

Example 2

Some usages:

In C

  1.   IupSetAttribute(texto, "VALUE", "Olá!");
  2.   IupSetAttribute(indicador, "VALUE", "ON");
  3. struct
     {
       int x;
       int y;
     } myData;

     IupSetAttribute(texto, "myData", (char*)&myData);

See Also

IupGetAttribute, IupSetAttributes, IupGetAttributes, IupStoreAttribute