Defining and Activating Tabs

To use a tab widget (utab or utabex), you need to create a main form that contains the Tab or TabEx widget, and one or more additional forms to contain the contents to be displayed in each tab page.

You can then use ProcScript to activate the tab pages, set form focus, navigate between tabs, and control how tabs are closed. If you are using the utabex widget, you can dynamically control the appearance of the widget

Note:  Samples of the utabex widget are available on Rocket Community.

To define and activate tabs:

  1. Define a form component to be displayed as a page in the tab widget, and set the Window Type window property to Contained.

    This automatically defines a form as non-modal and attached, and overlays the previous form.

  2. Define another form component to contain the tab widget, and set the widget properties so that it s non-modal and attached.
  3. Define a non-database entity containing a Tab or TabEx widget field.
  4. In the widget properties, define the tabs the widget will contain in the Page Name and Tab Label Text ValRep list.
  5. Depending on which version of the tab widget you are using, you can define the layout and appearance of the tabs, either in the widget properties dialog or in ProcScript. The utabex widget provides extensive support for controlling the tab widget's look and feel.
  6. Assign an initial value that specifies which page to show first. You can:
    • Enter the contained form instance name in the Initial Value field of the widget properties.
    • In the exec operation of the parent form, assign the value of a contained form to the tab widget. For example, TABFLD="FORM1".
  7. Set the form focus. You can:
    • Assign the instance name of the desired form to the tab widget field. Clicking a tab in the tab widget activates the valueChanged trigger, which passes the value associated with the tab label to the tab widget. The active page then overlays all other pages displayed in the widget.
    • Use the setformfocus statement with the instance name of a contained form to make that page active. By default, focus is given to the tab label not the contained form, so you cannot switch tab pages using the setformfocus statement. However, after a page is made active (by clicking a tab), use setformfocus to move focus to the form rather than the tab label.
  8. To activate tab pages, you can:
    1. Activate all tab pages in the tab widget and give focus to a specific page. Use the newinstance and activate statements in the exec operation and assign the relevant contained form to the tab widget field of the parent form.

      For example:

      ;trigger _Execute 
         newinstance "CUST_INV"
         newinstance "CUST_PERSON"
         newinstance "CUST_ORDER"
         newinstance "CUST_DEBIT"
         activate "CUST_INV"
         activate "CUST_PERSON"
         activate "CUST_ORDER"
         activate "CUST_DEBIT"
         TABFLD="CUST_PERSON" ;tab widget field = first form
         edit ;to be activated
    2. Control how pages are activated, use the valueChanged trigger for the tab widget field.

      For example, you can activate one page on opening the parent form, and control all other page activation using the valueChanged trigger.

      operation exec
         newinstance "CUST_PERSON"
         activate "CUST_PERSON"
         TABFLD="CUST_PERSON"
         edit
      end
      
      trigger _ValueChanged 
         if ($instancechildren="CUST_PERSON")
            selectcase TABFLD
               case "CUST_ORDER"
                  newinstance "CUST_ORDER"
                  activate "CUST_ORDER"
               case "CUST_DEBIT"
                  message "Access denied."
               case "CUST_INV"
                  newinstance "CUST_INV"
                  activate "CUST_INV"
            endselectcase
         endif
      end
  9. To store data, you can:
    • Use the postmessage statement to pass information between the pages.
    • Use operations to execute store and validation procedures.
  10. To close tabs, you can define command buttons to close pages in the widget.

    However, this creates an empty page, leaving the tab label visible. The closed page can only be activated again by an explicit activate statement.

Related Topics