OriginLab Corporation - Scientific Graphing and Data Analysis Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis

Associating LabTalk Script with an Object


All objects such as text labels, rectangles, lines, arrows, and other annotations have associated Programming Control dialog boxes. The Object Control dialog box is used to name the object (mostly for programmatic control) and to define the object's LabTalk script and script execution trigger. An example of a script execution trigger would be the clicking of a button that you have created to run a script that you have associated with the button object.

In the following example, you create a button from a text label and program the button so that, when clicked on, it opens an attention message that says "Hello World!"

Contents

Creating the text label

  1. Click the New Graph button Image:Button_New_Graph.png on the Standard toolbar to open a new graph window.
  2. Select the Text tool Image:Button_Text_Tool.png from the Tools toolbar and click in a blank area of the graph. This starts the in-place text editing mode.
  3. Type Hello World.
  4. Press ESC to de-select the label. The "Hello World" text label displays on the page.

Converting the label into a button

  1. Click on the label and then select Format: Programming Control.
  2. Click in the text box at the bottom of the dialog box and type in the following text (this is the script for the control):
    type -b "Hello World!";
  3. Select Button Up from the Script, Run After drop-down list.
    The Button Up option informs Origin that the script is executed when the button is clicked. Each of the options from the Script, Run After drop-down list establish a different method for script execution. For example, select Moved to execute the associated script when the text label is moved.
  4. Click OK to close the dialog box.

The Hello World text label now displays on your screen as a button. When you click the button, an Attention dialog box opens and displays:

Image:Associating_LabTalk_Script_with_an_Object1.png

Tip: This button object will not print. If you wish to print a graph with a button, do this:

  1. From the Origin menu, choose Edit: Button Edit Mode.
  2. Right-click on your button object and select Programming Control.
  3. Set the Script, Run After drop-down list to None and click OK.
  4. Right-click on your text object and select Properties.
  5. Set Background to Dark Marble and click OK.
  6. Choose Edit: Button Edit Mode to exit button edit mode.

You will now be able to print your graph, complete with a reasonable representation of your button.

Editing the button text or script

Once the button is activated, you must invoke Button Edit Mode to edit the button details -- the button label, the script behind the button, etc.

Image:HelloWorld1.png

To invoke Button Edit Mode:

  1. From the menu, choose Edit: Button Edit Mode.
    The Button Edit Mode menu command will have a check mark next to it when Button Edit Mode is active. The button object's appearance will be changed; note the word "Text " appearing in the upper left corner of the label.
    Image:Text EditMode.png
    Button functionality is now disabled and the object can be edited as if it were any other text object.
    • To edit the button label, right-click on the object and select Properties.
    • To edit the button's script, page attachment method, script triggering event, etc., right-click on the object and select Programming Control.
    • To delete the button object, right-click on the object and select Delete (or press DELETE).
  2. When you have finished editing the button details, reselect the Edit: Button Edit Mode menu item (removing the check mark from beside the menu item). This turns off button edit mode and restores the functionality of any script-associated objects in the project.