All posts by Clinton Reese

Widget Notes

The UI-Widgets Package library has a couple of nodes.

Widget shortcut – can assign shortcuts to the widget as a whole
Widget toolbar – opens a toolbar when the widget is active and closes it along with the widget

The shortcuts only seems to work with simple lower case characters, numbers and some lower case symbols.
The toolbar only works with 1 toolbar at a time. More than one and they sit on top of each other. It seems to open the toolbar near the mouse position.

tS WindowsManager Notes

WindowsManager.CloseToolbar operates on the ID not the Prototype of the toolbar

WindowsManager.OpenToolbarFromPrototype(“Main”, 100, 100, 0, 0); uses the Prototype not the ID these values 100,100 is location, 0,0 are dummy size to just fit the toolbar

//frame snapping constants
//_WindowsManager.h
//enum _tagRtWindowCorner
//} 	RtWindowCorner;
WINDOW_CORNER_TOP	= 0
WINDOW_CORNER_BOTTOM	= 1
WINDOW_CORNER_LEFT	= 2
WINDOW_CORNER_RIGHT	= 3
WINDOW_CORNER_CENTER	= 4
WINDOW_CORNER_VERTICAL_CENTER	= 5
WINDOW_CORNER_HORIZONTAL_CENTER	= 6
WINDOW_CORNER_CLIENT_CENTER	= 7
WINDOW_CORNER_CLIENT_VERTICAL_CENTER	= 8
WINDOW_CORNER_CLIENT_HORIZONTAL_CENTER	= 9
WINDOW_CORNER_LEFT_TOP	= 10
WINDOW_CORNER_LEFT_BOTTOM	= 11
WINDOW_CORNER_RIGHT_TOP	= 12
WINDOW_CORNER_RIGHT_BOTTOM	= 13
WINDOW_CORNER_CLIENT_TOP	= 14
WINDOW_CORNER_CLIENT_BOTTOM	= 15
WINDOW_CORNER_CLIENT_LEFT	= 16
WINDOW_CORNER_CLIENT_RIGHT	= 17
WINDOW_CORNER_CLIENT_LEFT_TOP	= 18
WINDOW_CORNER_CLIENT_LEFT_BOTTOM	= 19
WINDOW_CORNER_CLIENT_RIGHT_TOP	= 20
WINDOW_CORNER_CLIENT_RIGHT_BOTTOM	= 21
WINDOW_CORNER_TITLEBAR_RIGHT_TOP	= 22

//only seems to work for actual corners, and offsets set to 0
//WINDOW_CORNER_CLIENT is target and source is WINDOW_CORNER
//snaps the source frame to the target, the second to the first
//HRESULT STDMETHODCALLTYPE SnapFrameToFrameEx( 
//            /* [in] */ BSTR bszFrameTarget,
//            /* [in] */ BSTR bszFrameSource,
//            /* [in] */ VARIANT iFrameTargetCorner,
//            /* [in] */ VARIANT iFrameSourceCorner,
//            /* [in] */ VARIANT iOffsetX,
//            /* [in] */ VARIANT iOffsetY)

//can not figure this one out at all, same args except no offsets
//STDMETHODCALLTYPE SnapFrameToFrame( 

Saving and Loading Toolbars

If you try to save a toolbar to disk it will save as empty without any buttons. Workaround is to create the toolbar in the Toolbar Prototypes Encapsulator then save the Toolbar Prototypes Encapsulator to disk. Reload into trueSpace in a different location and remove all the toolbars except for the toolbar of interest, optionally rename the encapsulator and save to disk. Now loading this encapsulated toolbar won’t loose the buttons.

trueSpace Toolbar Button Bug?

When a script is called from a toolbar button using ScriptObject.Execute, the script will not be able to read node connection values, Node.Value If the same script is called from a toolbar button using Activity.Run then it can read the values without an error.

As noted in another post the Node.Value will also fail inside a script function set. The fix is to use RsApp.RunScriptBuffer

GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");GlobalFS.Parent();

will fail when run from a toolbar button because GlobalFS.Parent() has a Node.Value in it.

cmd='GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");GlobalFS.Parent();';RsApp.RunScriptBuffer(cmd);

wrapped in a script buffer command and it works

Truespace Script Buffer

trueSpace scripts create an undo step for each command in the script that changes the graph. So a single script can have many undo steps generated. The trueSpace script buffer will run a collection of script commands in the form of a string and generate only 1 undo.

Function Set variables can be used to pass complex data structures to the buffer.

If Node.Value() is used inside of a function set then it cannot be called directly from a toolbar button. The Node object seems to be incomplete and will fail with an warning message in the log, but no alert dialog like normal errors. If called using the script buffer command the Node.Value function will work when called from a toolbar button.

var cmd = ''
// note that if System.ThisOwner() is included in the buffer tS will crash
var thisowner = System.ThisOwner()
cmd += var owner = "' + thisowner + '";'
cmd += 'System.Trace(owner)'
RsApp.RunScriptBuffer(cmd);

trueSpace Delete Bug

When selected items are deleted the Node commands still behave as if the selection exists. Code below shows how to check for a valid selection before using it.

// Execute 
// Called to execute the command 
function Execute(params)
{
    if(!IsValidSelection(Node.Selection())) return;
    System.Trace("selection is good");
}
function IsValidSelection(selection)
{
    if(!selection) return false;
    var reWhiteSpace = /^\s/; // whitespace in first character
    var selectionArray = selection.split(";");
    for(var i = 0; i < selectionArray.length; i++) {
        var selClean = selectionArray[i].replace(reWhiteSpace, "");
        if(!Node.Exists(selClean)) {
            return false;
        }
    }
    return true;
}