I'd like to show/hide a breed of links according to the value of a Switch in the UI. I know how to show/hide links when the corresponding procedure is embedded in a setup or go procedure, but I am wondering if I can detach my visible-links procedure in order to call it whenever I want, even if the go button is not pressed:
ifelse show-diffusions? ;; this is my Switch element
[ask diffusions [set hidden? false]]
[ask diffusions [set hidden? true]]
Should I simply add a new button that goes forever and use it to let the user call the visible-links procedure? It would be somewhat ugly, but if that is the only way I'd go for it.
Best How To :
Adding another "forever" button would be an overkill. There is another solution, but it changes your user interface.
I suppose you have a switch control named
show-diffusions? which is automatically a global variable in NetLogo. Instead of that switch control create a global variable
show-diffusions? and a button
Show-hide-switch procedure can switch on and off the diffusions visibility and render the links.
set show-diffusions? true
ask diffusions [ set hidden? not show-diffusions? ]
; this is called by a button Show-hide-switch
set show-diffusions? (not show-diffusions?)
; or call display if necessary