Page 1 of 1

Undocumented function —> gTBo()

PostPosted: Sat Feb 08, 2020 9:52 pm
by Clifton
For those who are using XML configuration files, you may find the internal PowerPac function gTBo() to be very useful.
This function enables direct access to PowerPac's Object Referencing Engine.

Syntax:
var obj = gTBo( [object, object name or id], [option] );

[option] can be one of the following:
  • [option] = "objRef" will return the DOM object with the submitted [name or id]
  • [option] = "tbObj" will return the ToolBook object with the submitted [name or id]
  • [option] = "id" will return the ToolBook id for the object with the submitted [name] OR it will return the DOM id for the object with the submitted [name]
  • [option] = "name" will return the ToolBook name OR the id in the case of a <make> object.
Example:
<!--(XML function that defines a click event on a ToolBook field; purpose is to change the styling of the field.)-->
<function name="myClick" event="click" params="evt,undef,target,mX,mY,isShift,isCntrl" useTB="true">
<![CDATA[
  var obj = gTBo( this.name, "objRef");
obj.style.border = "2px solid blue";
obj.style.padding = "10px";
obj.style.height = "auto";
obj.style.width = "auto";
obj.style.color = "rgba( 255, 128, 0, 0.5)";
]]>
</function>

While many styles are supported using pgStyleObject(), rgba() is not and so this may be the only way to access this style. The function also may be useful when accessing obj.innerHTML as well as other properties. It may also be more efficient when setting custom or user properties for objects rather than using tbfunction_userProperty().

It all comes down to convenience and readability of your code.