Context and Variables

It can be cumbersome to always use a variable's fully qualified name. In some cases it is more convenient to address a variable by its context of use. For example, render extensions are always associated with a control and in many instances the properties that they associate to variables will also be local to that control. In this situation it would be more convenient to refer to a variable as being 'local to the control'. Storyboard supports this through the use of a data context shorthand that can replace a variable's fully qualified name.

The data context is the context of execution of a particular activity. For render extensions, this means the parent control of the render extension. For actions, this means the model element associated with the triggering event. The shorthand notation is a string formatted as ${@@CONTEXT:NAME} where CONTEXT is going to be one of app, screen, group, layer, or control indicating the model element in context to resolve, while the NAME is the name of the variable being addressed.

To reduce complexity of using the fully qualified model paths and to minimize the maintenance effort as a project evolves or changes, Storyboard defines several variable shortcuts that will expand their value based on the current model context in which they are being resolved.

${app:varname}Refers to the application variable varname.
${screen:varname}Refers to the screen variable varname.
${layer:varname}Refers to the layer variable varname.
${group:varname}Refers to the group variable varname.
${control:varname}Refers to the control variable varname.

For example, in the following Storyboard model:

Application
 + MainScreen
   + ALayer
     + AGroup
       + AControl

where the current focus is associated with the control AControl, reference to a variable varname would resolve to a fully qualified path as follows:

${app:varname}varname
${screen:varname}MainScreen.varname
${layer:varname}ALayer.varname
${group:varname}ALayer.AGroup.varname
${control:varname}ALayer.AGroup.AControl.varname

For tables, where the context also includes the row and column index of the table cell being adjusted, a special ${cell:CONTEXT:NAME} notation can be used that converts the variable shorthand into a variable that contains the row and column as a postfix to the standard variable name. For example, if the current focus or selection was directed a table control named ATable on the cell that was occupying row five and column one then the following would be variable expansions:

${cell:app:varname}varname.5.1
${cell:group:varname}ALayer.AGroup.varname.5.1
${cell:control:varname}ALayer.AGroup.ATable.varname.5.1