>
|
|
>
|
|
>
|
|
Executing the ToggleButton command produces a function call.
>
|
|
By using commands from the Layout Constructors 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 "ToggleButton0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "ToggleButton0" 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.
>
|
|
| (1) |
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
The next example makes use of action code for a toggle button. When the button is toggle 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.
>
|
|
>
|
|
>
|
|
| (4) |
>
|
|
>
|
|
The ToggleButton component in the previous example is constructed by supplying identity="ToggleButton0" 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 ToggleButton in the last example can be replaced at insertion time. Note that literal instances of "ToggleButton0" are also replaced in the component action code of the inserted content in the last example. In particular the replacement of the literal instance of "ToggleButton0" in the actioncode string will match the identity replacement. This allows the action code to function as intended, with component identities and references replaced consistently. This can be confirmed by selecting the inserted ToggleButton and viewing the component name in the Context Panel and by clicking Edit Click Code... to view the Code Editor for this component.