
A short tutorial demonstrating the closing and opening of forms.
Opening forms in BrightBuilder operates utilising a stack, with forms opening on top of one another, and closing in sequence. When a form is opened, a new instance of the form is created and displayed at the top of the stack. Only the top-most form in the stack may be interacted with by the user, until closed.
Forms in BrightBuilder may be assigned to be opened from any control’s action properties. The form which initiates the opening is known as the parent form, while the form that is opened is known as the child form. To establish this relationship, you can either double click on a form control or click on the ellipsis […] of the Action properties of a control. At this point the following dialog will appear:
Selecting 'Open a Form' will open the Form Open Dialog.
The child form may then be set using the Open Form dropbox, which lists all forms of the project. If parameterised queries are linked in the child form via listviews, combo boxes and/or data binding, the parameters of these queries may be assigned a data source under the Parameter section. Similarly, child forms will also have their variables listed in the Variable section.
Pre-Open/Post-Close expressions which are in the parent form and use the parent’s data sources may also be assigned, under the Pre-Open and Post-Close Expression menus. If expressions need to be done in a similar way but with the child’s data sources, the expression should be in the child and the child form’s Action Properties should be used.
Forms may also be opened explicitly through expressions, using the Form.ChildFormOpen() and supporting object methods. As BrightForms executes expressions sequentially, lines of code called past this call will execute after the child form is closed.
Closing a form can be done by default at any time by the user through the close button (or OK button on mobile devices). However, if you wish to alter this (or any other default form behaviour) you may set the Form > Properties > CancelClose variable as true to disallow this.
Furthermore, forms may be closed explicitly using the Object > Form.Close() method. This can be called any time in any expression.
Example Expression
IF variable == "yes"
{
Form.CancelClose = false;
Form.MessageBox("Success", "OK", 0);
}
ELSE
{
Form.CancelClose = true;
Form.MessageBox("Error", "Problem with input", 0);
}
Form.Close();
Have the form open on the listviews Action – Double Click property.
Set the parameter of the form to the ID of the selected item in the listview with listview1.GetCurrentRowColumnValue("ID"), and set the Action – Open expression as ‘onOpen’, which will load the name into the QuestionForm’s name_label variable.
Have the close button on the QuestionForm check if the answer is "yes" or "no", if it is have the form close, if not, cancel the close.
A completed solution is in the OpenCloseFormFinished.bsp file.