Jump to content

How to dynamically Add ui widgets on button press UAK


silageman
 Share

Recommended Posts

#include "UltraEngine.h"

 

using namespace UltraEngine;

 

 

int main(int argc, const char* argv[])

{

 

    auto displays = GetDisplays();

    auto window = CreateWindow("Add Buttons", 0, 0, 640, 480, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE);

    auto ui = CreateInterface(window);

    auto sz = ui->root->ClientSize();

    array<shared_ptr<Widget>, 10> btn;

    int inc = 0;

    int space = 0;

    btn[0] = CreateButton("add", 0, 0, 100, 100, ui->root);

    while (true)

    {

        const Event ev = WaitEvent();

        switch (ev.id)

        {

        case EVENT_WIDGETACTION:

                if(ev.source == btn[inc]){

                    space=space+100;

                    btn[inc+1] = CreateButton("+", 0,space, 100, 100, ui->root);

                    Print(inc);

                    inc= inc+1;

                    break;

                }

            break;

        case EVENT_WINDOWCLOSE:

            return 0;

            break;

        }

    }

}

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...