So I have some checkboxes that are equivalent. Meaning (in this case) that 1=2=3. I'm trying to make it when you check/uncheck any of 1 2 or 3, it will check/uncheck the others. I can get it to set them, but once I set them. There's not an obvious way to check which one was unchecked. Because of the constraint I have where everything has to be local in the funciton box. So I can't have a Last_selected variable or anythign like that.
Here's what I've tried so far.
new window("Test",
cb = checkbox({"1", "2", "3", "4", "5"});
);
eq = Associative Array({{1, {2, 3}}, {2, {1, 3}}, {3, {1, 2}}});
cb <<Set Function(
Function({self = cb},
items = self << Get Items;
sel = self << Get Selected;
for(i=1, i<=nitems(sel), i++,
id = Num(sel[i]);
if(eq << Contains(id),
equivalencies = eq[id];
for(k=1, k<=nitems(equivalencies), k++,
remove from(sel, Contains(sel, char(equivalencies[k])) );
);
for(k=1, k<=nitems(items), k++,
if(Contains(equivalencies, Num(items[k])) ,
self << Set(k, 1)
);
)
)
);
)
)