Libraries‎ > ‎Library‎ > ‎Interface gadgets‎ > ‎

Create chooser

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Create a chooser of values for a parameter.

End description

Create chooser

Begin NetLogo code:

substitute-text-area-for chooser-variable the-choice-between-a-b-or-c         
substitute-text-area-for upper-left-corner-x 5    
substitute-text-area-for upper-left-corner-y 250 
substitute-text-area-for lower-right-corner-x 80   
substitute-text-area-for lower-right-corner-y 300
substitute-text-area-for chooser-default-selection 3 
substitute-text-area-for chooser-choices "2" "a" "c" 2.5 5
create-chooser 
  "chooser-variable" ; name of global variable
  "upper-left-corner-x" "upper-left-corner-y" ; upper left corner (from the upper left corner of the applet) 
  "lower-right-corner-x" "lower-right-corner-y" ; lower right corner
  "chooser-default-selection" ; index of default selection (index zero is first in list!)
  chooser-choices ; choices quoted and separated by spaces

End NetLogo code

Variants

All the text area parameters can be changed.

How this works

This creates a NetLogo chooser for a parameter (i.e. a global variable) named in the first text area. The user can choose between the values listed in the last text area. The parameter is set to the chosen value.

Related micro-behaviours

History

Create chooser was implemented by Ken Kahn.

BehaviourComposer: ignore everything after this.

Comments