Dynamic control creation

Post Reply
arbuxMusic
Posts: 49
Joined: Sun Aug 25, 2019 10:26 am

Dynamic control creation

Post 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?
User avatar
Captain
Posts: 103
Joined: Sat Aug 25, 2018 11:12 am

Re: Dynamic control creation

Post 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).
arbuxMusic
Posts: 49
Joined: Sun Aug 25, 2019 10:26 am

Re: Dynamic control creation

Post by arbuxMusic »

That's great news - thanks!
tristanshoutsf
Posts: 11
Joined: Sun Jan 02, 2022 1:58 am

Re: Dynamic control creation

Post 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.
terrymcg
Posts: 85
Joined: Mon Apr 08, 2019 12:35 am

Re: Dynamic control creation

Post 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
Post Reply

Return to “Module Designer”