I'm not totally clear on how the above three ways to interact with variables all work together. I was originally under the impression that they all operated on the same "variables" context for a given widget, but a situation I encountered earlier today made that seem like that wasn't the case.
I have a matrix widget (matrix_1
) where I was setting a variable in the "variables" property, and then using it in the props property (i.e. @{this.variables.myvariable} or @{matrix_1.variables.myvariable}
) for that widget and another widget. I set the props property to include:
props.onValue = "setVar('matrix_1', 'myvariable', 'some new value')"
for my matrix children. However, when I interacted with that widget and the onValue script for the matrix child was triggered, the widgets that used @{matrix_1.variables.myvariable}
were not updated with the new value.
Using the console, I checked some things:
getProp('matrix_1', 'variables').myvariable
> returned old value
getVar('matrix_1', 'myvariable')
> returned new value
Based on other posts, it looks like VAR{} and set/getVar both operate on the same variables, but it wasn't clear if that variable context is the same as the widget "variables" property, so I wanted to confirm the behavior or see if it was a bug.
Thanks!