Google Classroom - Interaktiva lektioner
GeoGebraGeoGebra Classroom - Interaktiva lektioner

Making a button to toggle visibility

Introduction

o toggle anything, you need to switch it between two states, so using Boolean variables is perfect here. The Boolean variable will in this case control the visibility of an object, and the script will change it's state, using the NOT operator. (This side originally created by Jonas Hall)

Sample construction

When to use

This is very useful since many times you do not want to leave the algebra window open to the user:
  • Toggle the visibility of parts of geometric construction, to remove clutter
  • Allow the user to "go into depth" by showing the next level of stuff
  • General control

How do you do this?

The construction above uses the following KEY ELEMENTS:
  • An object to be controlled: In this case the point A.
  • A Boolean variable: Make sure you name it appropriately. Once it is created, put it's name in the conditional visibility field on the Advanced tab of the objects properties dialogue.
  • A button which script controls the Boolean variable: The script to toggle the value of a Boolean variable from true to false or vice versa is SetValue[b, ¬b] where ¬ is the Boolean NOT operator and b is the name of the Boolean variable.

Screencast of construction

More examples