Page 1 of 1

Create Control by Name

Posted: 01 Aug 2020, 13:04
by armin.it
Hi,

It is possible creating a control by his name

For example like

Control ct = new Control(„Button“)

Re: Create Control by Name

Posted: 03 Aug 2020, 11:53
by jsantos
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.

Re: Create Control by Name

Posted: 03 Aug 2020, 12:25
by armin.it
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".

Re: Create Control by Name

Posted: 03 Aug 2020, 19:38
by jsantos
You can use the C++ factory for that:
#include <NsCore/Factory.h>

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