>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?
I don't sure if is related, but when GUI, the things is different from linear 
execution.

Try:
        IupMainLoop();
before print attributes.

#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);
        IupMainLoop();

        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]);
        }
        IupClose();
}

regards
Ranier Vilela

_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to