AddChildComponent() - how does it work?

Post Reply
User avatar
Captain
Posts: 103
Joined: Sat Aug 25, 2018 11:12 am

AddChildComponent() - how does it work?

Post by Captain »

When I try to use AddChildComponent() for any GUI element, the child component simply disappears? For example, I have two text labels, and do this in the code:

Code: Select all

textLabel1.AddChildComponent( textLabel2 );
As soon as I do that, textLabel2 disappears from the interface. I have tried moving both components, setting their visibility to true, etc, but textLabel2 stays awol. Is there something super obvious I'm missing? The only documentation I found is the short javadoc description...
User avatar
rsover
Posts: 54
Joined: Wed Mar 04, 2020 1:53 pm
Location: Romania
Contact:

Re: AddChildComponent() - how does it work?

Post by rsover »

I think the parent component should be a container component. https://docs.oracle.com/javase/tutorial ... index.html

I have not done VMDesiner development so far, but could be a solution.
Voltage Modular, Arturia V7 Collection / Ableton Live 11 Intro

MacBook Pro 2019, 2,3 GHz 8-Core Intel Core i9 (16GB Ram), OSX Big Sur (11.x)
Cherry Garcia
Site Admin
Posts: 293
Joined: Fri Aug 31, 2018 2:57 am

Re: AddChildComponent() - how does it work?

Post by Cherry Garcia »

Set the position relative to the parent. That should help.
User avatar
Captain
Posts: 103
Joined: Sat Aug 25, 2018 11:12 am

Re: AddChildComponent() - how does it work?

Post by Captain »

Cherry Garcia wrote: Mon Feb 22, 2021 2:20 am Set the position relative to the parent. That should help.
Yes, now I got it, thank you! But it also seems that the child component needs to be inside the parent's bounding rectangle, the rest is cut off. No problem, I just thought that the parent-child-relationship would simply mean locking the components' coordinates to each other, no matter what their initial placement is (like the "Link selected controls" option), that's what threw me off. :)
rsover wrote: Sun Feb 21, 2021 8:19 pm I think the parent component should be a container component. https://docs.oracle.com/javase/tutorial ... index.html
Yeah, indeed it looks like the parent component is treated like a container. What confused is me that you can add children to all GUI elements (text labels, buttons, etc), which don't "feel" like containers the same way a canvas does, for example. :D
Cherry Garcia
Site Admin
Posts: 293
Joined: Fri Aug 31, 2018 2:57 am

Re: AddChildComponent() - how does it work?

Post by Cherry Garcia »

(= Glad you got it figured out. The upcoming Piano Roll module uses child components extensively. Each note object is a VoltageRectangle inside of VoltageViewport. Hovering over a note object will add a label over the note object in order to show it's note value, for example. Should be coming up in the next month or so.
Post Reply

Return to “Module Designer”