Executing the ComboBox command produces a function call.
By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.
That XML representation of a worksheet can be inserted directly.
The previous example's call to the InsertContent command inserted a component with identity "ComboBox0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "ComboBox0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.
The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.
The next example makes use of action code for a ComboBox. When the selected item is manually altered the action code is executed.
The action code updates a PlotComponent with identity "Plot0", which will be an additional part of the inserted content. This component will be constructed using the Plot Component constructor.
The action code consists of multi-line statements supplied as a string.
Following insertion an item in the ComboBox may be manually selected, which causes the respective action code to execute and the "Plot0" component to be updated.
The ComboBox component in the previous example is constructed by supplying identity="ComboBox0" as an option. But the first example on this page had already inserted content with a component with that identity. Hence the identity of the ComboBox in the last example may be replaced at insertion time. Note that literal instances of "ComboBox0" are also replaced in all component action code of the inserted content in the last example. In particular the replacement of the literal instance of "ComboBox0" in the actioncode string will match the identity replacement. This allows the action code to function as intended, with component identities replaced consistently. This can be confirmed by selecting the inserted ComboBox and viewing the component name in the Context Panel and by clicking Edit Select Code... to view the Code Editor for this component.