Difference between revisions of "OnClick"

(Created page with "Category:Attributes ''new to Analytica 4.6'' The OnClick attribute is used withButton and Picture objects and contains an Expression Syntax|expressi...")
 
m
Line 2: Line 2:
 
''new to [[Analytica 4.6]]''
 
''new to [[Analytica 4.6]]''
  
The [[OnClick]] attribute is used with[[Buttons|Button]] and Picture objects and contains an [[Expression Syntax|expression]] that gets evaluated when the button is pressed.  
+
The [[OnClick]] attribute is used with [[Buttons|Button]] and Picture objects and contains an [[Expression Syntax|expression]] that gets evaluated when the button is pressed.  
  
 
The expression can contain side-effects. For example, within the expression, you can assign to a global variable using the := operator. Such side-effects are not permitted in variable definitions. The result of the evaluation is not saved and is never used. Hence, the whole purpose of the expression is to enact some sort of side-effect.
 
The expression can contain side-effects. For example, within the expression, you can assign to a global variable using the := operator. Such side-effects are not permitted in variable definitions. The result of the evaluation is not saved and is never used. Hence, the whole purpose of the expression is to enact some sort of side-effect.

Revision as of 04:42, 13 February 2014

new to Analytica 4.6

The OnClick attribute is used with Button and Picture objects and contains an expression that gets evaluated when the button is pressed.

The expression can contain side-effects. For example, within the expression, you can assign to a global variable using the := operator. Such side-effects are not permitted in variable definitions. The result of the evaluation is not saved and is never used. Hence, the whole purpose of the expression is to enact some sort of side-effect.

The expression syntax is the same as the syntax for a Definition attribute.

An OnClick expression has available to it two variables named click_x and click_y, which contain the coordinates of the mouse within the button or image. For a button, these coordinates are relative to the top-left corner of the button. For a Picture node, they are relative to the top-left corner of the image (in general, this may be different from the top-left corner of the node). If the button was "pressed" using the keyboard, or from typescript by typing the button's name, or by some other means not involving the mouse, click_x and click_y are both Null.

OnClick replaces the Script attribute for buttons which was used prior to Analytica 4.6. The Script attribute is still present and still works (so that legacy models still work), but has the disadvantage that is uses Typescript, which meant that you had to learn something new. Since OnClick uses expression syntax, you don't have to learn something new.

The OnClick expression is always evaluated in mid-mode.

For Checkboxes and Choice pulldowns, use the OnChange attribute, not OnClick.

See Also

Comments


You are not allowed to post comments.