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.

When an attribute is set it is always stored at the hash table unless the driver disable the storage. If the value is NULL, the attribute will be removed from the hash table. Then the driver or the custom control is updated. Finally the attribute is also updated for the children of the element in the driver if they do not have the attribute defined in their own hash table.

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