Professional Documents
Culture Documents
TGML Scripting
Welcome TAC-MAI
User profile
Sea ch
Home
Product version
Concept
Functionalit
1.1
Language
Privileged
Products: Graphics Editor
Functionalities: Graphics
7/28/2011
English
Products
How to
Tutorials
TGML Scripting
Script Elem ent: Script
Target Area Elem ent: TargetArea
Developers Reference
TGML supports the script language JavaScript 1.5. A JavaScript editor is available in Graphics Editor. You can use the
JavaScript edtor to access the elements and their attributes in View mode. The script engine does not run in Edit mode.
Getting help
The DOM (the elements and their attributes) is accesed using DOM methods such as getCurrentTarget ,
getAttribute , and setAttribute .
Downloads
Apart from accessing the DOM, it is also possible to interact w ith the TGML View er, and thus the underlying system, using
StruxureWare-specific JavaScript functions such as setValue and e ecute .
Troubleshooting
The execution of the scripts is event driven. Event attributes are used to specify the event and a function name. The
function is executed in View mode w hen the specified event is raised.
Script defines a script block that belongs to the immediate parent element.
Global Variables
Variables declared outside the Java script functions are global w ithin the script block. The global variables exist w hile the
TGML document is displayed (executed) in Dynamic mode.
The global variables can only be accessed by the functions that are defined in the same script block.
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
1/8
2/10/12
TGML Scripting
TGML code w ith an example of how you can convert a varible to a number
Description
getCurrentTarget() Returns the element the Script belongs to. That is, the EventTarget w hose EventListeners are
currently being processed.
getTarget()
Returns the element to w hich the event w as originally dispatched. For example, the element you
clicked.
preventDefault()
If the event is cancelable, preventDefault cancels the default action normally taken by the
implementation, for example, the view er.
stopPropagation
When an element contains Bind or Link, the view er is supposed to respond w hen the user clicks the element. The view er is
supposed to respond by show ing a change value dialog box or opening the linked presentation object. This is the view er
default action that is canceled by the preventDefault function.
preventDefault in an OnMouseClick function cancels the change value dialog box (w hen the element contains a Bind) or the
link function (w hen the element contains a Link).
preventDefault in an OnSignalChange function cancels the error indication indicated by a red cross.
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
2/8
2/10/12
TGML Scripting
Description
getButton()
getClientX()
Returns the X coordinate of the cursor, relative the origin of the target coordinate system.
The coordinate is calculated using the transformations of the target element.
getClientY()
Returns the Y coordinate of the cursor, relative the origin of the target coordinate system.
The coordinate is calculated using the transformations of the target element.
getCurrentTargetX()
Returns the X coordinate of the cursor, relative the origin of the current target coordinate
system.
The coordinate is calculated using the transformations of the current target element
getCurrentTargetY()
Returns the Y coordinate of the cursor, relative the origin of the current target coordinate
system.
The coordinate is calculated using the transformations of the current target element.
getCurrentTargetParentX()
Returns the X coordinate of the cursor, relative the origin of the current target's parent
coordinate system.
The coordinate is calculated using the transformations of the current target's parent.
getCurrentTargetParentY() Returns the Y coordinate of the cursor, relative the origin of the current target's parent
coordinate system.
The coordinate is calculated using the transformations of the current target's parent.
getScreenX()
Returns the X coordinate of the cursor, relative to the origin of the document coordinate
system.
getScreenY()
Returns the Y coordinate of the cursor, relative to the origin of the document coordinate
system.
Description
getStatus()
getPresentationValue()
getUnit()
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
3/8
2/10/12
TGML Scripting
getValue()
Mehtod
Any
getChild
element (" name ")
Description
Returns the immediate child element that has the Name attribute w ith the given value. If no
such child exists, this returns null. If more than one immediate child element has a Name
attribute w ith that value, w hat is returned is undefined.
Any
getChildRecursive Returns the child element at any level that has the Name attribute w ith the given value. If no
element (" name ")
such element exists, this returns null. If more than one element has a Name attribute w ith that
value, w hat is returned is undefined.
Any
getFullBindName() Returns the exposed name of the Bind or Link element, including names of parent
element
components.
Method
Description
Any
element
Any
element
getChildNodes()
Any
element
getOw nerDocument()
Any
element
getParentNode()
Any
element
getTagName()
Any
element
Sets the value of attribute to value . If the element does not have the attribute, it
is created as a TGML custom attribute.
Document getDocumentElement()
Returns the child element that has the Id attribute w ith the given value
Document getElementsByTagName
(" tagName ")
Returns a NodeList of all the elements in document order w ith a given tag name
NodeList
getLength()
NodeList
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
4/8
2/10/12
TGML Scripting
Description
alert("<messages>")
clearInterval(intervalID)
clearTimeout(timeoutID)
confirm("<message>")
execute("<commande>"),
execute("<command>", "
<options>")
invoke("<bindingName>", "
<operation>")
Requests an operation to be performed on a bound object by the TGML view er. The
bindingName is the full name (as it is exposed to the binding tools) of a Bind or Link
element.
Returns true if succeeded or false if failed.
Note: The implementation of this function is system dependent. May not be implemented in
some systems.
openFile("<path>", "
<operation>")
Request the TGML view er to open a file. The operation is typical Window s object verbs.
Returns true if succeeded or false if failed.
Note: The implementation of this function is system dependent. May not be implemented in
some systems.
prompt("<message>", "
<defaultValue>")
setForce("<bindingName>", "
<true|false>")|
Sets the force state of a bound signal object. The bindingName is the full name (as it is
exposed to the binding tools) of a Bind element.
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
5/8
2/10/12
TGML Scripting
some systems.
setInterval("<expression>", "
<milliseconds>")
Evaluates (executes) the expression each time the specified number of milliseconds has
elapsed.
Returns an identifier that cancels the timer w ith the clearTimeout method.
setTimeout("<expression>", "
<milliseconds>")
Evaluates (executes) the expression after the specified number of milliseconds has
elapsed.
Returns an identifier that cancels the timer w ith the clearInterval method.
setValue("<bindingName>", "
<value>")
Sets the value of a bound signal object. The bindingName is the full name (as it is exposed
to the binding tools) of a Bind element.
Returns true if succeeded or false if failed.
Note: The implementation of this function is system dependent. May not be implemented in
some systems.
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
6/8
2/10/12
TGML Scripting
TGML code that starts an interval timer and animates (toggles) the fill color w hen the pointer is placed over the rectangle.
The timer is stopped and the color is restored w hen the pointer is moved from the rectangle.
TGML code w here an alert box is displayed w hen the pointer is held over the rectangle for one second. The timer is stopped
w ehn the pointer is moved from the rectangle.
JavaScript 1.5
For more information, see ECMASc ip Lang age Specifica ion, Re . 3. .
See Also
TGML Script Element: Script
TGML Target Area Element:
TGML Signal Binding:
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
7/8
2/10/12
TGML Scripting
Communit Content
Add new content
help.struxureware.schneider-electric.com/Topics/show.castle?id=5716&locale=en-US&productversio
8/8