>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  User

Tab Control

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
There are two uses for tab controls:

  • You can set up a single set of controls, and use the tab control to switch between different values for the controls. In this case, the controls in the tab area are created in the same form as the tab itself.

  • You can set up several forms, and use the tab control to switch between forms. In this case, the forms should be created separately from the main form.

    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:

       load 'system\examples\demo\days.ijs'

    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'
    wd 'creategroup'

    This code:

  • uses creategroup to prepare to load forms for the tabs control
  • loads each form to be shown on the tabs control
  • uses creategroup with 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.

    >>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  User