LabTalk:User created Visual Objects (Object)

From OriginLab Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 08:05, 22 January 2009 (edit)
Echo (Talk | contribs)
(Available General Methods:)
← Previous diff
Revision as of 08:06, 22 January 2009 (edit) (undo)
Echo (Talk | contribs)
(Available General Methods:)
Next diff →
Line 365: Line 365:
* Simulate a click on the ''n''th hot spot of the object. Multiple hot spots are a feature of UIM objects. * Simulate a click on the ''n''th hot spot of the object. Multiple hot spots are a feature of UIM objects.
-<pre>+<lt>
object.click(n) object.click(n)
-</pre>+</lt>
* Redraw the ''object''. ''Option'' = local to redraw hot spots. ''Option'' = global to redraw the entire object. * Redraw the ''object''. ''Option'' = local to redraw hot spots. ''Option'' = global to redraw the entire object.
-<pre>+<lt>
object.draw(option) object.draw(option)
-</pre>+</lt>
* Run the script of the ''object''. * Run the script of the ''object''.
-<pre>+<lt>
object.run() object.run()
-</pre>+</lt>
===Example=== ===Example===

Revision as of 08:06, 22 January 2009

Contents


Visual objects can also be created by the Origin user and placed in an Origin child window. These objects include labels, arrows, lines, and other user-created graphic elements. These objects are accessed from script by their name, as defined in the associated Label Control dialog box.

To open the Label Control dialog box:

  1. Select Edit:Button Edit Mode to enter Button Edit Mode.
  2. Click on the object, then select Format:Label Control.
  3. Enter the desired name in the Object Name text box.
  4. Click OK to close the dialog box.

Scripts can be attached to these labels by typing the script into the text box of the Label Control dialog box. The Script execution trigger is set from the Script, Run After drop down list.

In general, only named objects can be accessed from LabTalk script. However, an unnamed object can be accessed by a script from within its own Label Control dialog box with this. notation, as described below.


Syntax of The User-Created Visual Object Properties

[winName!]objName.property = value

or

this.property = value

  • WinName! is optional. It specifies the window that the named object resides in. This is useful when there are several objects with the same name in a project.
  • objName is the object's name, as entered in the Object Name text box in the Label Control dialog box.
  • Property is one of the available objName properties.

Available General Properties

The generic properties of these objects are listed below. (Note that not all properties are available for all objects.)

Property Access Description

object.arrowBeginLength

Read/write, numeric

Length of beginning arrow heads in point size.

object.arrowBeginShape

Read/write, numeric

Shape of beginning arrow heads by position in drop down list, Object Control dialog box: 0 = none, 1 = filled, 2 = chevron, etc.

object.arrowBeginWidth

Read/write, numeric

Width of beginning arrow heads in point size.

object.arrowEndLength

Read/write, numeric

Length of end arrow heads in point size.

object.arrowEndShape

Read/write, numeric

Shape of end arrow heads by position in drop down list, Object Control dialog box: 0 = none, 1 = filled, 2 = chevron, etc.

object.arrowEndWidth

Read/write, numeric

Width of end arrow heads in point size.

object.arrowPosition

Note that object.arrowBeginShape
and object.arrowEndShape must also
be set.

Read/write, numeric

Controls the display of arrow heads for each line segment of polyline and freehand objects:

0 = no arrow heads.
1 = arrow at beginning of each segment.
2 = arrow at end of each segment.
3 = arrow at both ends of each segment.

object.attach

Read/write, numeric

Attach to method:

0 = layer
1 = page
2 = axes scales

object.auto

Read/write, numeric

Redraw automatically after property changes: 0 = disable, 1 = enable.

object.background

Read/write, numeric

Control the background of an object as follows: 0 = no background, 1 = black line, 2 = shadow, 3 = dark marble, 4 = white out, and 5 = black out.

object.color

Read/write, numeric

Line, text, or outline color index number. Use the color() function, as in name.color=color(red);

object.dx, object.dy

Read/write, numeric

Width and height in axes units.

object.enable

Read/write, numeric

Enable hotspots on the object: 0 = disable, 1 = enable.

object.event

Read only, numeric

The object's script execution: 1 = run script when button is clicked, 0 = all other events.

object.fillColor

Read/write, numeric

Shape object fill color index number. Use the color function, as in name.fillcolor = color(red);

object.font

Read/write, numeric

Text label font index number. Use the font() function, as in name.font = font(arial);

object.fSize

Read/write, numeric

Text label font size.

object.height

Read only, numeric

Height in layer coordinate units.

object.hMove

Read/write, numeric

Horizontal movement: 0 = disable, 1 = enable.

object.index

Read only, numeric

Only applicable for objects composed of multiple items, such as the UIM objects. Indicates which item in an object has been affected by a Windows action.

(Note: The UIM is a component of OriginPro. For more information, contact OriginLab or your Origin distributor.)

object.keepInside

Read/write, numeric

Restrict object's movement to within the layer frame: 0 = disable, 1 = enable.

object.left

Read/write, numeric

Left location of the object in physical coordinates.

object.lineType

Read/write, numeric

Line and arrow object line type: 1 = solid, 2 = dash, and 3 = dot.

object.lineWidth

Read/write, numeric

Line or arrow object line width.

object.mouse

Read/write, numeric

Mouse access to the object: 0 = disable, 1 = enable.

object.name$

Write only, string

Object name.

object.realTime

Read/write, numeric

Real-time update of substitution notation in a text label message: 0 = disable, 1 = enable.

object.revVideo

Read/write, numeric

Reverse video display: 0 = disable, 1 = enable.

object.rotate

Read/write, numeric

Text label rotation in degrees.

object.script

Read/write, numeric

Script, Run After mode index number, from the drop-down list in the Label Control dialog box.

object.show

Read/write, numeric

Object display: 1 = visible, 0 = hidden. Hidden objects are not selectable

object.states

Read/Write, numeric

Controls object edit states. The property is bit-oriented so that values can be added.

Example: polygon.states = 3, disables resizing and rotating for the object named polygon.

0 = all controls are enabled.
1 = resizing is disabled.
2 = rotating is disabled.
4 = skewing is disabled.
8 = moving individual points is disabled.
16 = in place editing is disabled.
32 = resize text label border disabled.
64 = horizontal movement is disabled.
128 = vertical movement is disabled.

object.text$

Read/write, string

Message displayed by a text label.

object.top

Read/write, numeric

Top of the object in physical coordinates.

object.vMove

Read/write, numeric

Vertical movement: 0 = disable, 1 = enable.

object.width

Read only, numeric

Width in layer coordinate units.

object.x, object.y

Read/write, numeric

Axes X Y coordinates of the center of the object.

object.x1, object.x2,
object.y1, object.y2

Read/write

x1 and y1 are the axes position of the first drawn point of the object (for example, the start location of a line).

x2 and y2 are the axes position of the last drawn point of the object (for example, the end location of a line).

For more control over drawing lines, see the draw - l command.

Methods:

The syntax of the user-created object methods is as follows:

[winName!]objName.Method(arguments)

or

this.Method(argument)

  • WinName! is optional. It specifies the window that the named object resides in. This is useful when there are several elements with the same name in a project. </nowiki>
  • objName is the object's name, as typed in the Object Name text box in the Label Control dialog box.
  • Method is one of the available objName methods.
  • arguments are specific to the method.

Available General Methods:

Append the contents of stringVariable or my string to a text label. Requires a screen refresh to view the change.

    object.addText(stringVariable)
    object.addText(my string)

Examples:

  • Append text.
%A=append this text;
text.addtext(A); // Note: use A not %A
text.addtext('append this text'); // Note: use quotation marks.

  • Simulate a click on the nth hot spot of the object. Multiple hot spots are a feature of UIM objects.
object.click(n)

  • Redraw the object. Option = local to redraw hot spots. Option = global to redraw the entire object.
object.draw(option)

  • Run the script of the object.
object.run()

Example

  • The following script uses the addText method to add text to the text1 label. Note that the string variable argument does not include the percent character.
%Z = " added to end of line";
text1.addtext(Z);
%Z="
added as a new line";
text1.addtext(Z);
text1.draw(global);
  • The next script disables horizontal movement for the Arrow object in the Graph2 window.
Graph2!Arrow.hmove = 0;
  • When entered in the Script window, the next script types the X and Y coordinates of the center of the Button object to the Script window.
Button.x =;
Button.y =;
  • The following script runs the script associated with an object named Mode in the Graph1 window.
Graph1!mode.run();
  • The last script uses the draw() method to redraw the WksData object in the Data2 window.
Data2!WksData.draw(global);