A tab control is a panel used to display other controls.
Commands applicable to the tab control are:
set tab text;
|add a tab label to the control|
setreplace tab n text;
|replace the text of a tab label|
setinsert tab n text;
|insert a tab label|
setdelete tab n;
|delete a tab label|
As an example of the first use, you could create controls that contain values for days of the week. Selecting the tab for the day changes the values of the controls accordingly.
For example, the following demo shows an edit control that depends on the day of week:
An example of the second type of tab control is the controls demo that displays the main Windows controls supported by J, see menu Studio|Demos|Controls.
In this example, the controls displayed on each tab were created in separate script files: system\examples\demo\control1.ijs, control2.ijs etc.
This second type of tab control uses the
creategroup command to allow several forms to be displayed in a single form.
A form definition used with a
creategroup command is an ordinary form that can be designed and tested with the form editor. It is loaded by the parent of the tab control by doing a
form_run'' that is bracketed by
creategroup commands. The first creategroup command gives the id of the tab control where the new controls are being created. The final
creategroup command has no parameter.
creategroup causes parent commands such as
pc to be ignored so that when the form definition is run, the child creates occur in the original parent form. The initial argument to
creategroup is an id, usually of a tab control, in the current form. Controls created under a
creategroup command are created as hidden, and as part of a group with the id from their (ignored)
pc command. The
setshow command with a group id, shows or hides the controls in a group.
For example, here is the relevant code from the controls demo:
wd 'creategroup tabs' edits_run'' selects_run'' wd 'creategroup'
creategroupto prepare to load forms for the
creategroupwith no parameter to finish up
Note that a tab control should be created before any controls that appear on top of it
- this ensures controls will be painted properly.
The event data for a tab control is the label text and the
id_select variable contains the index of the selected tab.