An interesting question came up on the web board this week. Is it possible to have a control which appears on all the forms of the project? For example, could you have a navigation bar which appears at the top of all the forms of the project?
It turns out this is quite easy to do.
Add the following code to your Sub Main():
Sub Main() NSBPage.appendChild(NavBar1) End Sub
The same, in JavaScript:
function Main() { NSBPage.appendChild(NavBar1); {
NSBPage is a special control: it is the highest level container in an AppStudio project. Each form is a child of NSBPage.
In the code above, NavBar1 starts as a child of Form1. The .appendChild() function moves NavBar1 from Form1 onto Form1’s parent, NSBPage. NavBar1 then appears on top of the current form, even if it changes. It has become a global control.
Event code for NavBar1 can be put anywhere in the project. Clicking on the NavBar will find the NavBar1_onclick() function, wherever it is.
You can control the appearance of NSBPage in Project Properties. The style, backgroundImage and backgroundColor properties all work.
This technique will work for any control.