Manuals >User's Guide >Creating Graphic User Interfaces
Print version of this Book (PDF file)
prevnext

Data Input Slider (Example)

This example shows the use of the Widget Properties dialog box to create a small GUI with two linked input/output items in it.

In the main window click Tab Model Gui Items. A menu of GUI manipulation commands appears at the left.

To start a new GUI from the left menu Select Add...

A large dialog box is displayed titled Widget Properties.

In the Name: box edit the default name UntitledChild, changing it to topFrame.

From the Select Type box pick Table from the dropdown list.

Once a widget type has been chosen an Options list appears.

Select Caption from the Options list and a new dialog box appears on the right.

Add the caption name Slider in the Enter Text Value box and click OK in the box.

Select Orientation and pick Horizontal from the dropdown list, then OK.

Click OK at the bottom of the Widget Properties box.

The text in the main window will now look like this:

Click on the text to select it.

Select Display...

An empty table captioned Slider appears.

We will now add a slider and a value display to the GUI.

With the text in the main window still selected, click Add Child...

The Widget Properties box appears.

Edit the Name to Slider.

Click the button in the Select Type box and select Slider.

From the Options list select Current Position.

In the Editing: Current Position panel click the Track Variable box.

Click on the Variable box and enter sliderVal and OK in the box under it.

Click OK in the bottom left box.

The text in the main window will now look like this:

Note the node symbol which indicates that there is now hierarchy in the GUI.

Click on the node. It will rotate, and the contents will be shown.

Before the slider can communicate its Current Position in the variable we named sliderVal, this variable has to be declared to the system.

In this example we will do it by clicking on the Model Variables tab. A table, probably empty will appear. On the name side type sliderVal.

Note that a value for sliderVal appears automatically.

Now click the Model GUI Items tab.

Select the top level item Slider (Horizontal Table...

Click Add Child...

The Widget Properties dialog box appears again.

In the Select Type box click Edit Text.

Edit Name to Show Value.

Select Field Value in the Options list, set Track Variable, and set the variable name to sliderVal, and click OK directly underneath it.

The slider GUI now looks as shown below.


Note


When the slider is moved, the numerical value displayed changes. Also, when the number is edited, the slider position moves in response, acting as an output device.



prevnext