TDResources

From Derivative
Jump to navigation Jump to search

TDResources is a component containing system resources for TouchDesigner, some of which are available for use in your projects. Access TDResources using its Global OP Shortcut: op.TDResources. Note: Access to these resources will be maintained in future versions of TouchDesigner, but the look of them may change. For example, the system popMenu will always be available, but the colors and font may change.

Pop-Up Menu[edit]

The system pop-up menu, which is a clone of popMenu, is available via op.TDResources.op('popMenu').Open(...). It is commonly used for RMB option menus and has 2 layers of sub-menus available for use as well. Example code:

op.TDResources.op('popMenu').Open(['Go', 'Stop'], callback=debug, callbackDetails=['test'])

For full documentation, see Palette:popMenu and PopMenu Custom COMP Examples.

Button Pop-Up Menu[edit]

The system button pop-up menu, which is also a clone of popMenu, is available via op.TDResources.op('buttonPopMenu'). It is commonly used for menus that pop up when a button is pressed and you want to align the menu to that button, but can technically be used to align a menu to any Panel Component. It does not have sub-menus available.

The difference between this and the system pop-up menu above is that it is meant to be attached to a button and the Buttoncomp, Horizontalattach, and Verticalattach parameters must be set before calling Open. Example code:

buttonPopMenu = op.TDResources.op('buttonPopMenu')
buttonPopMenu.par.Buttoncomp = op('/myButtonPanel')
buttonPopMenu.par.Horizontalattach = 'Left'
buttonPopMenu.par.Verticalattach = 'Top'
buttonPopMenu.Open(['Go', 'Stop'], callback=debug, callbackDetails=['test'])

For popMenu documentation, see Palette:popMenu and PopMenu Custom COMP Examples.

Pop-Up Dialog[edit]

The system pop-up dialog, a clone of popDialog, is available via op.TDResources.op('popDialog').OpenDefault(...). It is used for simple pop-up dialogs with up to four options and an optional text entry box.

There is a nice code example of this here.

For full documentation, see Palette:popDialog, popDialog Extension and PopDialog Custom COMP Examples.

Mouse[edit]

There is mouse information in a CHOP available for system use in op.TDResources.op('mouse/out1'). This can be used to get the mouse state without needing your own Mouse In CHOP. You can see all the channels and access this information by using a Select CHOP. You can also access it directly using code:

mouse = op.TDResources.op('mouse/out1')
normalizedMouseX = mouse['tx']
absoluteMouseX = mouse['abs_mouse_x']
leftButton = mouse['left_button']