|
|
Home » U++ Library support » TreeCtrl » Missing callback trigger in OptionTree? [SOLVED/FIXED]
Missing callback trigger in OptionTree? [SOLVED/FIXED] [message #3549] |
Thu, 01 June 2006 11:29 |
James Thomas
Messages: 26 Registered: June 2006
|
Promising Member |
|
|
I've got an OptionTree in my application and I would like to dynamically repond to state changes (ie: an option being checked).
This cannot be accomplished by assigning a callback to each Option control because OptionTree used this callback to implement it's hierarchical checking (when you check a parent option it also checks it's children).
Now, OptionTree has a Callback called WhenOption that is never triggered. I suspect that this was intended to be used for the purpose of allowing a response to a state change but was forgotten.
I believe it should be put into OptionCtrl::SetOption as follows:
void OptionTree::SetOption(int id)
{
Option *opt = option[id];
ASSERT(opt);
SetChildren(id, opt->Get());
for(;;) {
id = GetParent(id);
if(id < 0)
break;
bool t = false;
bool f = false;
bool n = false;
for(int i = 0; i < GetChildCount(id); i++) {
int chid = GetChild(id, i);
Option *opt = option[chid];
if(opt) {
int x = opt->Get();
if(x == 1)
t = true;
else
if(x == 0)
f = true;
else
n = true;
}
}
opt = option[id];
if(opt) {
if(t && f || n) {
opt->Set(Null);
}
else
opt->Set(t);
}
}
WhenOption(); <<-------- This is the addition
}
With the extra line the control now works as I would expect. I can't see any other reason for WhenOption, so is this how it should work?
[Updated on: Fri, 02 June 2006 12:15] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Wed May 15 03:46:12 CEST 2024
Total time taken to generate the page: 0.02053 seconds
|
|
|