BehaviourComposer: ignore everything before this.
Begin micro-behaviour:
Begin description:
Create a button with associated NetLogo code.
End description
NetLogo button
Begin NetLogo code:
substitute-text-area-for upper-left-corner-x 5 substitute-text-area-for upper-left-corner-y 225 substitute-text-area-for lower-right-corner-x 107 substitute-text-area-for lower-right-corner-y 255 substitute-text-area-for button-label Click me! substitute-text-area-for netlogo-code ask patches [set pcolor red] substitute-text-area-for keyboard-shortcut A substitute-text-area-for repeat-forever false add-button '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 'button-label' ; label (cannot contain single quotes) '(netlogo-code)' ; action 'keyboard-shortcut' ; keyboard shortcut 'repeat-forever' ; if true then this button will repeat its action forever
End NetLogo code
All the parameters can be changed by editing the text areas. If you don't want a keyboard shortcut then remove the last line of code.
This creates a NetLogo button. The last parameter, the action, is available to micro-behaviours such as Do button command as the value of the button-command variable.
If this button changes the heading or position of the agent then add Display current turtle state at the end of the list of button behavioursto ensure that the agent's appearance is updated when the button is clicked regardless of whether the model is running or not.
Netlogo code button can be used to add NetLogo code to a button (instead of micro-behaviours as this one does).
NetLogo button was implemented by Ken Kahn.
BehaviourComposer: ignore everything after this.