Hi,
There is a small error here:
IupOpen(&argc, &argv);
But it is not related with the IupGetAllAttributes behavior.
This:
int names_count = IupGetAllAttributes(text, NULL, -1);
Returns the maximum number of that call may return. Those 7 are all
internal attributes, so the next call actually return 0. If you change to:
names_count = IupGetAllAttributes(text, names, names_count);
It will print nothing.
Best,
Scuri
Em qui., 30 de jul. de 2020 às 17:35, Matthew Kennedy <[email protected]>
escreveu:
> I have some basic code in C that creates a couple of elements and tries to
> print out the list of attributes associated with one of them (a text area
> in the example below), but when I run it, all the attribute names I
> expected to see are NULL even though IupGetAllAttributes said there would
> be several (7 in this example). I must be doing something obviously wrong,
> and to be honest, I've forgotten most of programming in C...
>
> Any ideas one what I'm doing wrong here?
>
> #include "iup.h"
> #include <stdlib.h>
> #include <malloc.h>
> #include <stdio.h>
>
> int main(int argc, char** argv) {
> IupOpen(argc, argv);
> Ihandle *text = IupText(NULL);
> IupSetAttribute(text, "MULTILINE", "YES");
> IupSetAttribute(text, "EXPAND", "YES");
> Ihandle *button = IupButton("Press me", NULL);
> Ihandle *box = IupVbox(text, button, NULL);
> Ihandle *dialog = IupDialog(box);
> IupSetAttribute(dialog, "SIZE", "320x200");
> IupShow(dialog);
>
> int names_count = IupGetAllAttributes(text, NULL, -1);
> printf("attribute count: %d\n", names_count);
> char **names = calloc(names_count, sizeof(char*));
> IupGetAllAttributes(text, names, names_count);
> for (int i = 0; i < names_count; i++) {
> printf("attribute: %s\n", names[i]);
> }
> IupMainLoop();
> IupClose();
> }
>
>
> Output
>
> attribute count: 7
> attribute: (null)
> attribute: (null)
> attribute: (null)
> attribute: (null)
> attribute: (null)
> attribute: (null)
> attribute: (null)
>
>
>
> _______________________________________________
> Iup-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users