AppendChild does not work as I've done it here

Form2.appendchild(CoIcons) where CoIcons is a container (with icons on Labels) on a different form… Up-to-date AppStudio, on PC Windows using Chrome, iPad Mini and Android LG Venture.

Test_AppendChild.nsx (27.7 KB)

Here are a couple things to look at:

  1. Do the appendChild inside Sub Main():
Sub Main()
  Form2.appendChild(CoIcons)
End Sub

That way it is done after all the controls are created.

  1. Set ‘openMode’ in Form2’s properties to True. Otherwise, it will stay hidden when you app opens.

The attached text app contains 3 forms… (the buttons are for your convenience)…

Using OpenMode causes the identified OpenMode Form to be opened when the app opens, in addition to what Form is scheduled to open… it doesn’t seem to have any impact on whether the Container shows or not.

The Form with the Container NEVER shows the container regardless if I use the
‘Sub Main()
FormN.appendChild(CoIcons)
End Sub’
or not. (a hopeful workaround for this is to set up a Form that just contains the Container and never reference it except for the appendChild code…I suspect I can set that to OpenMode, but hidden, so I don’t get the problem noted in the second paragraph above… interesting aside… when the OpenMode Form opens, it opens in ‘double size’, regardless of the ScreenMode setting).

the bigger issue is that the appendChild only seems to work on the LAST Form… e.g., with three Forms, each with the AppendChild code, Form 1 is no show (of Container), Form 2 is no show and Form 3 shows Container… I blocked commented Form 3 out and now only Form 2 Container shows (vs. a no show if three is active.)

Test_AppendChild.nsx (45.2 KB)

Using most recent version of AppStudio (6.2.7), Windows 10 with Chrome, iPad Mini and Android LG Venture.

You have 3 instances of sub Main(). The browser will likely run the last one parsed.

I can make your app append the icon container anywhere I put the code to do so. What exactly are you trying to accomplish? Do you want the icon container on each page as it is shown? Keep in mind there is only one instance of the container object, so it will only show on the last place you append it to.

Buck, in answer to your question, I want the 4 ‘navigation’ icons to appear on every form and I was hoping NOT to have to copy the code (for each icon) in every form… not a big deal to do that, but seems pretty heavy handed to me. So this thread, with input from George plus one other person, has been about trying to accomplish one set of icons and one hunk of code to be applicable to all forms.

George had suggested the “Sub Menu”, but being a rookie, I did not realize I only needed to do that once… but then how do I append the Container to each Form? Your last sentence implies that using an FormN.AppendChild(ColIcons) (the Container holding the 4 icons) is not going to work on multiple forms.

Tom…

As I explained in the previous discussion, if you use ‘NSBPage.appendChild(YourObject)’ in the Sub Main function, your object will be added to every single form with this single command. The object will not show in the IDE, but when deployed it will be added to each form.
Helen

RESOLVED!

My apologies, Helen… I did not fully understand your first post and instead concentrated on Geoge’s first suggestion which “seemed” much easier. However, I haven’t been able to make it work… I tried your suggestion above (NSBPage.appendChild(CoIcons) and it works.

When I run the app on Windows, the Container is left justified on the screen, while all other objects on the screen are centered (Every Form is set to “Zoom”)… same thing happens on iPad Mini, but on the Android (LG Venture) ALL objects, including the Container, are centered (horizontally) on the screen as they should be. It’s still livable on the iPad Mini, but just not as pretty… I can live with that.

So thank you for solving this!

BR Tom