User guide
217
The Asset Control Widget
The AssetWidgetDelegate plug-in API makes it possible to replace the default string widget that allows users to view
and edit an Asset ID in the node Parameters tab.
Typically you edit the fields of an asset through a UI. Internally those fields are serialized into a single string as an
Asset ID, and stored as a parameter on a node.
Using a custom Asset Control Widget you can replace the widget displaying the fields. Katana knows to use the
custom widget through the assetIdInput hint, which is associated with all string parameters that represent an
Asset ID.
Implementing A Custom Asset Control Widget
The entry point that Katana needs, in order to create a custom asset control widget is the
createAssetControlWidget() method of our custom AssetWidgetDelegate class.
The createAssetControlWidget() method instantiates the SimpleMockAssetControlWidget, which must inherit
from BaseAssetControlWidget. BaseAssetControlWidget is a QT QWidget with an HBoxLayout.
createAssetControlWidget() then adds the control widget to the parent layout. The parent is a QWidget and part
of the Parameter tab.
The following methods must be implemented by an asset control widget:
• buildWidgets()
This is invoked by the BaseAssetControlWidget constructor to build the child widgets. This is where most of the
work happens.
• setValue()
Updates this widget with the given Asset ID.
• getValue()
Return the Asset ID from this widget.
• setReadOnly()
Enable/Disable editing of this widget.
The BaseAssetControlWidget supplies an emitValueChanged() method for notifying Katana that the user has
changed the Asset ID in the widget. This must be called when the value in the UI has changed.
27 ASSET MANAGEMENT SYSTEM PLUG-IN API | THE ASSET CONTROL WIDGET