armin.it
Topic Author
Posts: 8
Joined: 31 Jul 2020, 16:15

Create Control by Name

01 Aug 2020, 13:04

Hi,

It is possible creating a control by his name

For example like

Control ct = new Control(„Button“)
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Create Control by Name

03 Aug 2020, 11:53

Yes, there is an internal factory available for that. Please, indicate us more information about what you need and also the language you are using.
 
armin.it
Topic Author
Posts: 8
Joined: 31 Jul 2020, 16:15

Re: Create Control by Name

03 Aug 2020, 12:25

HI,
thanks, for your reply. At runtime (C++) I need to create buttons and other controls. A client sends a Message to my C++ GUI App like "Listbox01.add.Button:btn01",
and the GUI-App now should find the control with the name "Listbox01", create a new Button with the name "btn01", set die Clickevent to my standard eventhandler "DefaultButtonClick" which progess all button clicks in the Gui-App and finally append this new Button at the Listbox "Listbox01".
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Create Control by Name

03 Aug 2020, 19:38

You can use the C++ factory for that:
#include <NsCore/Factory.h>

Ptr<BaseComponent> CreateByName(const char* name)
{
    return Factory::CreateComponent(Symbol(name));
}

Who is online

Users browsing this forum: Google [Bot] and 10 guests