Page 1 of 1

Dynamic control creation

Posted: Wed May 27, 2020 11:58 am
by arbuxMusic
Some advice on module design please.

I can sort out creation / alignment much easier in code templates than through the designer, so am looking to code the control creation rather than design it. (The other alternative would have been to template up the controls, but I can't edit the constructor).

Are there any design compliance issues creating controls in the Initialize function rather than creating them through the editor?

Re: Dynamic control creation

Posted: Thu May 28, 2020 9:05 am
by Captain
I have done this a lot, and as far as I can see, it works just as well in initialize() as it does in the constructor, as long as you just do it the same way (create the control, AddComponent(...), set control params, etc).

Re: Dynamic control creation

Posted: Thu May 28, 2020 9:23 am
by arbuxMusic
That's great news - thanks!

Re: Dynamic control creation

Posted: Wed Aug 10, 2022 5:02 am
by tristanshoutsf
Just posting a couple notes in this old topic, so some future designer isn't stumped by this like I was:

If you do your own VoltageKnob construction using a skin that isn't part of a knob that was placed using the layout design tool, you'll need to make sure that that skin is included in the module's Extra Skins... list.

If you want to add a VoltageKnob as a child to a VoltageRectangle, as opposed to the module itself, the rectangle has to be marked with 'Wants Mouse Notification' in order for its child knobs to be editable.

Re: Dynamic control creation

Posted: Sat Aug 13, 2022 11:44 am
by terrymcg
tristanshoutsf wrote: Wed Aug 10, 2022 5:02 am If you do your own VoltageKnob construction using a skin that isn't part of a knob that was placed using the layout design tool, you'll need to make sure that that skin is included in the module's Extra Skins... list.
Ah, nice tip!

It's not just knobs of course, it's any GUI component that uses a skin not included by the editor. Traditionally, I've been creating hidden components that use the skin(s), but this is a much neater method.

Cheers,
--
Terry McG