Control Caption Display?

Dave Yrueta shared this question 2 years ago
Answered

Hi All --

Is it possible to link the display of captions to the value of a boolean variable?

I tried this -- in the Scripting Box for the object whose caption I wanted to display, I wrote If(ShowCaption==True, SetCaption(B, "hello"), SetCaption(B, "goodbye")) where B is a point and ShowCaption is a boolean. I got an "unbalanced bracket" error when I changed the value of the boolean. Not sure why.

Hopefully you can see my intention with the example. Any help figuring out how to do this would be much appreciated!

Comments (4)

photo
1

I think using the command SetLabel does the trick.

photo
1

Try it the other way round:

SetCaption(If(ShowCaption, "hello", "bye"))
or as you've found

ShowLabel(B, ShowCaption)

photo
1

That exact command works for me on the current web version of Geogebra. Which version are you using?


Have you placed that script in the OnUpdate control of the boolean (ShowCaption)? If you put it in the script for B, then that doesn't explain the Unbalanced Brackets error but it will not work as expected, because the script won't trigger unless B is updated - which it won't be if you simply toggle the boolean.

photo
1

Michael -- Thank you for the feedback! ShowLabel(B, ShowCaption) is much more compact than the If statement I was using.

pisquared -- It works now -- I can't explain why. User error I guess!

© 2023 International GeoGebra Institute