IupGetAttribute

Returns the name of an interface element attribute. See also the Attributes Guide section.

Parameters/Return

char *IupGetAttribute(Ihandle *ih, const char *name); [in C]
iup.GetAttribute(ih: ihandle, name: string) -> value: string, ihandle or userdata [in Lua] char *IupGetAttributeId(Ihandle *ih, const char *name, int id); [in C]
iup.GetAttributeId(ih: ihandle, name: string, id: number) -> value: string, ihandle or userdata [in Lua] char* IupGetAttributeId2(Ihandle* ih, const char* name, int lin, int col); [in C] iup.GetAttributeId2(ih: ihandle, name: string, lin, col: number) -> value: string, ihandle or userdata [in Lua]

ih: Identifier of the interface element. If NULL will retrieve from the global environment.
name: name of the attribute.
id, lin, col: used when the attribute has additional ids.

Returns: the attribute value or NULL (nil in Lua) if the attribute is not set or does not exist.

Utility Functions

These functions can also be used to get attributes from the element:

int    IupGetInt   (Ihandle* ih, const char* name);
int    IupGetIntInt(Ihandle* ih, const char* name, int *i1, int *i2);
int    IupGetInt2  (Ihandle* ih, const char* name);
float  IupGetFloat (Ihandle* ih, const char* name);
double IupGetDouble(Ihandle* ih, const char* name);
void   IupGetRGB   (Ihandle *ih, const char* name, unsigned char *r, unsigned char *g, unsigned char *b);
void   IupGetRGBA  (Ihandle *ih, const char* name, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a); (since 3.29)

int    IupGetIntId   (Ihandle* ih, const char* name, int id);          
float  IupGetFloatId (Ihandle* ih, const char* name, int id);
double IupGetDoubleId(Ihandle* ih, const char* name, int id);
void   IupGetRGBId   (Ihandle *ih, const char* name, int id, unsigned char *r, unsigned char *g, unsigned char *b);

int    IupGetIntId2   (Ihandle* ih, const char* name, int lin, int col);
float  IupGetFloatId2 (Ihandle* ih, const char* name, int lin, int col);
double IupGetDoubleId2(Ihandle* ih, const char* name, int lin, int col);
void   IupGetRGBId2   (Ihandle *ih, const char* name, int lin, int col, unsigned char *r, unsigned char *g, unsigned char *b);

[There is no equivalent in Lua]

IupGetIntInt retrieves two integers separated by 'x', ':' or ',' and returns the number of returned values (0, 1 or 2). IupGetInt2 returns just the second value.

Notes

See the Attributes Guide for more details.

The returned value is not necessarily the same pointer used by the application to define the attribute value. The pointers of internal IUP attributes returned by IupGetAttribute should never be freed or changed, except when it is a custom application pointer that was stored using IupSetAttribute and allocated by the application.

 The returned pointer can be used safely even if IupGetGlobal or IupGetAttribute are called several times. But not too many times, because it is an internal buffer and after IUP may reuse it after around 50 calls.

IupLua

In IupLua, only known internal pointer attributes are returned as user data or as an ihandle, all other attributes are returned as strings. To access attribute data always as user data use iup.GetAttributeData:

iup.GetAttributeData(ih: ihandle) -> value: userdata [in Lua]

Examples

Browse for Example Files

See Also

IupSetAttribute, IupSetAttributes, IupGetHandle, IupSetGlobal, IupGetGlobal