ReferenceupdateValue

<updateValue>

Updates one or more state variables on a target component

<updateValue> is a General Operator component that changes the value or property of a named component based on a button click interaction or a boolean condition.

Attributes and Properties

Attributes for <updateValue>

Labels (1)
labelIsName

boolean. Default value: false. Whether to use this component's name as its rendered label.

Positioning (2)
anchor

point. Default value: \(\left( 0, 0 \right)\). Coordinates of the anchor point used to position this component on a graph.

positionFromAnchor

keyword. Where this component sits relative to its anchor point.

ValueDescription
upperRightPlace the component above and to the right of the anchor point.
upperLeftPlace the component above and to the left of the anchor point.
lowerRightPlace the component below and to the right of the anchor point.
lowerLeftPlace the component below and to the left of the anchor point.
topPlace the component directly above the anchor point.
bottomPlace the component directly below the anchor point.
leftPlace the component directly to the left of the anchor point.
rightPlace the component directly to the right of the anchor point.
center (default)Center the component on the anchor point.
Triggering (4)

boolean. Default value: false. Boolean expression that fires the action whenever it transitions to true.

reference. References to components whose click events should fire this action.

triggerWhenObjectsFocused

reference. References to components whose focus events should fire this action.

reference. References to components whose value changes should fire this action.

Other (5)
draggable

boolean. Default value: true. Whether the update button can be dragged on a graph.

_componentWithSelectableType. New value to assign to the target.

simplify

keyword. Level of simplification applied to the new value.

ValueDescription
none (default)No simplification is applied.
fullFully simplify the new value.
numbersSimplify numeric subexpressions only, leaving symbolic structure intact.
numbersPreserveOrderLike numbers, but does not reorder commutative operands.
normalizeOrderReorder commutative operands into a canonical form without simplifying values.

reference. Reference to the state variable that will be updated.

keyword. Component type used to interpret the new value.

ValueDescription
mathTreat the new value as a math expression.
numberTreat the new value as a number.
booleanTreat the new value as a boolean.
textTreat the new value as text.
Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <updateValue name="u">

Labels (2)
$u.label

label. The label rendered with this component.

$u.labelIsName

boolean. Whether to use this component's name as its rendered label.

Positioning (2)
$u.anchor

point. The coordinates where this component is anchored on the graph.

$u.positionFromAnchor

text. Where this component sits relative to its anchor point.

Other (6)
$u.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$u.draggable

boolean. Whether the update button can be dragged on a graph.

$u.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$u.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$u.hidden

boolean. Whether this component is hidden from the rendered output.

$u.simplify

text. Level of simplification applied to the new value.

Common to all components (4)
$u.doenetML

text. The DoenetML source code that produced this component.

$u.hide

boolean. Whether to hide this component from the rendered output.

$u.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$u.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Change the color of a <circle>

An <updateValue> is used to change the styleNumber property of a named <circle> from the default value (11) to 22. Once this change occurs, the button becomes disabled.


Example: Change the value of a <number>

An <updateValue> is used to change the value of a <number> based on the number’s current value.

Attribute Examples

Attribute Example: target

The target attribute specifies which component or component property to update.


Attribute Example: type

The type attribute specifies the type of component that is changing. The default type is math, and valid values are math, number, boolean, or text.


Attribute Example: newValue

The newValue attribute specifies the new value for the target or target property.


Attribute Example: disabled

The disabled attribute takes a boolean condition. When the condition evaluates to true, the button becomes disabled.


Attribute Example: triggerWhen

The triggerWhen attribute establishes a boolean condition for triggering when the value should be updated. In this case, the circle turns blue when the correct answer is entered.


Attribute Example: triggerWith

The triggerWith attribute allows the update to occur based on interaction with another specified component. In this way, the actions of two or more <updateValue> components may be chained together.


Attribute Example: triggerWhenObjectsClicked

Updates can be triggered by click interactions with graphical components defined within a <graph> using the triggerWhenObjectsClicked attribute.