PDA

View Full Version : "Checkbox" button state and labels


kmartin7
08-25-2004, 02:04 PM
I have the following code in the onClick event for a label:

isChecked = Button.GetState("checkbox");
if (isChecked ~=true) then
Audio.ToggleMute(CHANNEL_BACKGROUND);
Button.SetState("checkbox", BTN_DOWN);
isChecked = true;
else
Audio.ToggleMute(CHANNEL_BACKGROUND);
Button.SetState("checkbox", BTN_UP);
isChecked = false;
end

I am trying to allow the user to click on the label and set an associated button's (checkbox) state. When I click on the label, the background music toggles like it should, and changes the button state to BTN_DOWN, but when I click it again, the music toggles but the button state does NOT change. Any ideas?

Kurt

Stefan_M
08-25-2004, 02:25 PM
change
if (isChecked ~=true) then
to
if (isChecked ~=1) then



take a look at the manual
Actions / Buttons / Button.Get State
Returns
(number) The current state of the button:

CONSTANT VALUE DESCRIPTION

BTN_UP 0 Button is up (normal).

BTN_DOWN 1 Button is down (pressed).




Stefan_M

yosik
08-25-2004, 03:54 PM
Kurt,
Just a quick point.
You want the user to click on a label and have a button change visually?
I would think the opposite would make more sense. One tends to click on what looks as abutton, and then, you can have something else (label, image...) changing accordingly.
I don't know what you intend to do and I may be WAY offline here, and if so..sorry about that.

Yossi

kmartin7
08-25-2004, 04:11 PM
Stefan,

That did the trick. For some reason, I thought I tried 1 instead of true, and got the same result...

Yosik,

If they click the button, they get the same effect. Clicking labels is pretty much a Windows form standard now, that if you click the checkbox or associated label, it will toggle the checkbox.

Kurt

Intrigued
08-25-2004, 05:06 PM
Stefan,

That did the trick. For some reason, I thought I tried 1 instead of true, and got the same result...

Yosik,

If they click the button, they get the same effect. Clicking labels is pretty much a Windows form standard now, that if you click the checkbox or associated label, it will toggle the checkbox.

Kurt
I like this feature! When keyboard navigating it's not important. But, when I am zooming through an install... It's nice to not have to get exactly on the dang option button, for example.