PDA

View Full Version : Two togglebuttons, one function, with maki


Michgelsen
18th February 2005, 19:57
Ok, I need to have two togglebuttons that control the same function.
Now, I started with one, which worked, and later added the second one.
When I click the second one, the first one is supposed to change along. That works, but the function the first one controls doesn't switch along.

Example: The first one is "on". Thus the second one looks as if it's "on". When I click the first one, it goes off, and the function it controls goes off. The second one looks off now too. Everything ok.
But, when they both are on and I click the second one, they both LOOK like they are off but they aren't! My notifier (that what it's for) still keeps poppin' up.

Here's my maki, what do I do wrong..?

//System.onScriptLoaded() section

onoff = eq.getObject("notifieronoff");
alwaysselector = eq.getObject("alwaysselector");
onoff2 = eq.getObject("notifieronoff2");
alwaysselector2 = eq.getObject("alwaysselector2");

if(getPrivateInt("AudioRack", "notifieronoff", on) == 1) {on = 1;}
if(getPrivateInt("AudioRack", "notifieronoff", on) != 1) {on = 0;}
if(on == 1) {onoff.setActivated(1); onoff2.setActivated(1);}
if(on == 0) {onoff.setActivated(0); onoff2.setActivated(0);}

if(getPrivateInt("AudioRack", "minimizedonly", always) == 1) {always = 1;}
if(getPrivateInt("AudioRack", "minimizedonly", always) != 1) {always = 0;}
if(always == 1) {alwaysselector.setActivated(1); alwaysselector2.setActivated(1);}
if(always == 0) {alwaysselector.setActivated(0); alwaysselector2.setActivated(0);}
}


Onoff.onLeftButtonUp(int x, int y) {
on = onoff.getActivated();
onoff2.setActivated(on);
}
Onoff2.onLeftButtonUp(int x, int y) {
onoff.leftClick();
}
Alwaysselector.onLeftButtonUp(int x, int y) {
always = alwaysselector.getActivated();
alwaysselector2.setActivated(always);
}
Alwaysselector2.onLeftButtonUp(int x, int y) {
alwaysselector.leftClick();
}

leechbite
21st February 2005, 02:07
maybe


onoff.onActivate(int on) {
onoff2.setActivatedNoCallBack(on==1);
}

onoff2.onActivate(int on) {
onoff.setActivatedNoCallBack(on==1);
}

Michgelsen
21st February 2005, 11:56
No that didn't work, but I tried to dubble code it:

Onoff.onLeftButtonUp(int x, int y) {
on = onoff.getActivated();
onoff2.setActivated(on);
}
Onoff2.onLeftButtonUp(int x, int y) {
on = onoff2.getActivated();
onoff.setActivated(on);
}

Alwaysselector.onLeftButtonUp(int x, int y) {
always = alwaysselector.getActivated();
alwaysselector2.setActivated(always);
}
Alwaysselector2.onLeftButtonUp(int x, int y) {
always = alwaysselector2.getActivated();
alwaysselector.setActivated(always);
}

That did work, although I still don't get why it didn't work the first time, because in fact it just says the same right?
I didn't want to use that at first because it felt a bit weird but I guess it's ok. It works now.

Then one other thing: what's the difference between setActivated() and setActivatedNoCallback()? What is it that NoCallback adds?

BTW thanks for your help. I feared this topic would be forgotten since it's already 3 days ago I posted it.

leechbite
22nd February 2005, 02:29
setActivatedNoCallBack() is same with setActivated() except it wont call the function onActivate(int on). :)

Michgelsen
22nd February 2005, 18:45
Oh ok I get it. Thanks!