Difference between revisions of "Action Objects"

From GeoGebra Manual
Jump to: navigation, search
(→‎Drop-down lists: fixed Eng name of the menu item, typo, format)
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<noinclude>{{Manual Page|version=4.0}}[[Category:Manual (official)|{{PAGENAME}}]]</noinclude>
+
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{objects}}
{{objects}}
+
For interactive worksheets with [[Scripting|scripting]] Action Objects may come handy.<br>
For interactive worksheets Action Objects may come handy. There are four types of them
+
There are four types of them:
 
==Checkboxes==
 
==Checkboxes==
Checkboxes are graphical representations of [[Boolean values]]. See [[Check Box to Show / Hide Objects Tool]] for details.
+
Checkboxes are graphical representations of [[Boolean values]]. See [[File:Mode showcheckbox.svg|link=|22px]] [[Check Box Tool]] for details.
==Text fields==
+
Checkboxes can be created using the aforementioned tool or the [[Checkbox Command]].
Textfields work as text inputs for [[Scripting|scripts]]. The script is triggered by changing text in the textfield and either pressing enter or leaving the textfield. The inserted value may be accessed using the %0 variable.
+
==Input Boxes==
{{example|Textfield with <code>a=a+%0</code> in script will increase number ''a'' by the entered value.}}
+
Input Boxes work as text inputs for [[Scripting|scripts]]. The script is triggered by changing text in the Input Box and either pressing enter or leaving the Input Box. The inserted value may be accessed using the %0 variable.
If you want the textfield to change value of a free object (or redefine dependent object), you may define that object as linked. This way you don't have to insert any script.
+
{{example|1=Input Box with <code>a=a+%0</code> in script will increase number ''a'' by the entered value. Works only if ''a'' is [[Free, Dependent and Auxiliary Objects|free]].}}
 +
If you want the Input Box to change value of a free object (or redefine dependent object), you may define that object as linked. This way you don't have to insert any script.<br>
 +
Input Boxes can be created using the [[File:Mode textfieldaction.svg|link=|22px]] [[Input Box Tool]] or the [[InputBox Command]].
 
==Buttons==
 
==Buttons==
==Comboboxes==
+
Buttons are meant to trigger scripts by being clicked. Although scripts can be triggered by clicking any other object (e.g. an [[Image Tool|image]]), using buttons for this makes your worksheet more intuitive.<br>
Comboboxes are available only in [[Spreadsheet View]]. You may enter a list into spreadsheet cell and then turn on option ''Use Buttons and Checkboxes'' in Spreadsheet Tab of [[Options Dialog]]. The list will turn into a combobox; the selected element may be obtained using [[SelectedIndex Command]] and [[SelectedElement Command]].
+
Buttons can be created using the [[File:Mode buttonaction.svg|link=|22px]] [[Button Tool]] or the [[Button Command]].
 +
==Drop-down lists==
 +
If you want to show the contents of a list, organized in a drop-down list:
 +
* in the [[File:Menu view graphics.svg|link=|16px]] [[Graphics View]]: check the ''Draw as drop-down list'' box in the ''Basics'' tab of the [[File:Menu-options.svg|link=|18px]] [[Properties Dialog]] of the list.
 +
* in the [[File:Menu view spreadsheet.svg|link=|16px]] [[Spreadsheet View]]: enter a list into the spreadsheet, then check the ''Use Buttons and Checkboxes'' box in the [[File:Menu view spreadsheet.svg|link=|16px]] ''Spreadsheet Options''.
 +
The selected element of a drop-down list may be also obtained using [[SelectedIndex Command|SelectedIndex ]] and [[SelectedElement Command|SelectedElement ]] commands.
 +
 
 +
{{example| To create a  drop-down list with three functions <code>x+1</code>, <code>x^2</code>, <code>sqrt(x)</code>, first create a list by typing
 +
<code>L={x+1, x^2,sqrt(x)}</code> in the input bar. Then right-click the list in ''Algebra View'' and select ''Object Properties...''. Select the ''Draw as drop-down list'' option in the appearing dialog window. You can also enter a caption that describes the drop-down list. In order to plot in ''Graphics View'' the currently selected function, enter the command <code>SelectedElement(L)</code> in the input bar .}}

Revision as of 09:27, 10 March 2018


For interactive worksheets with scripting Action Objects may come handy.
There are four types of them:

Checkboxes

Checkboxes are graphical representations of Boolean values. See Mode showcheckbox.svg Check Box Tool for details. Checkboxes can be created using the aforementioned tool or the Checkbox Command.

Input Boxes

Input Boxes work as text inputs for scripts. The script is triggered by changing text in the Input Box and either pressing enter or leaving the Input Box. The inserted value may be accessed using the %0 variable.

Example: Input Box with a=a+%0 in script will increase number a by the entered value. Works only if a is free.

If you want the Input Box to change value of a free object (or redefine dependent object), you may define that object as linked. This way you don't have to insert any script.
Input Boxes can be created using the Mode textfieldaction.svg Input Box Tool or the InputBox Command.

Buttons

Buttons are meant to trigger scripts by being clicked. Although scripts can be triggered by clicking any other object (e.g. an image), using buttons for this makes your worksheet more intuitive.
Buttons can be created using the Mode buttonaction.svg Button Tool or the Button Command.

Drop-down lists

If you want to show the contents of a list, organized in a drop-down list:

  • in the Menu view graphics.svg Graphics View: check the Draw as drop-down list box in the Basics tab of the Menu-options.svg Properties Dialog of the list.
  • in the Menu view spreadsheet.svg Spreadsheet View: enter a list into the spreadsheet, then check the Use Buttons and Checkboxes box in the Menu view spreadsheet.svg Spreadsheet Options.

The selected element of a drop-down list may be also obtained using SelectedIndex and SelectedElement commands.

Example: To create a drop-down list with three functions x+1, x^2, sqrt(x), first create a list by typing L={x+1, x^2,sqrt(x)} in the input bar. Then right-click the list in Algebra View and select Object Properties.... Select the Draw as drop-down list option in the appearing dialog window. You can also enter a caption that describes the drop-down list. In order to plot in Graphics View the currently selected function, enter the command SelectedElement(L) in the input bar .
© 2024 International GeoGebra Institute