I have a level editor with a test button that I want to change into a toggle button - I want it to turn on when pressed and stay on until pressed again. Currently I have a setup like this
With it coded that way, it stays toggled on when you first press it and while you hold down the mouse button, but as soon as the mouse goes up it toggles off instantly. That led me to think that when you give a Toggle a bool parameter it automatically toggles it when it is pressed, but that makes it function like a normal button and it will only run the 'else if (false)' block.
Just in addition to Eric's answer:
A Toggle just switches between two states. It doesn't have something like "onMouseDown" or "onMouseUp" events. It just turns the variable on when you click it once (and it stays on) and when you click again it turns off again (and stays off)
I have to admit that the example on the Toggle page is terrible.
To detect a state change you just have to store value of your state variable from the last frame and compare it with the current. If it's different a change has occurred.
With a toggle you can simplify it like this:
Now the toggle works just like a normal button. The only difference is that you have an active state which changes it's visual appearence.