I initially posted this on bugs but it is really just a programming problem so
I am moving to this forum.
The problem is that I have defined my own class to hold data for an fltk2
browser.
have assigned the list to the browser.
I fill the list from a data base query which then shows in the list.
The list works fine up to a point. I can select, sort and muliselect.
But when i double click (I want to show a form with more detailed info on
double clicking -sort of drill down) the application crashes - even if even
nothing happens in the call back. So it is in my class or in the interface
between my class and the browser.
Doing a trace in call back it seems to be a problem int he relayout event.
This is visible flag is requested on a null pointer. Presumabale some sort of
null widget returned by my class but I cant see what I am doing wrong.
My ugly debugging code follows :
fltk::Widget* BrowserList::child(const fltk::Menu*, const int* indexes, int
level) {
unsigned int row;
static fltk::Widget* widget = 0;
//only accept first level
if (level) return 0;
// if (level == 0)
// if (indexes[0] >= data.size()) return 0;
// if ((unsigned int) level == 1) return 0;
// if (level > 0) return 0;
//if (level = 1)
// if (indexes[l] >= v->size()) return 0; NOTIMPLEMENTED YET
if (!widget) {
fltk::Group::current(0);
widget = new fltk::Item();
}
row = indexes[level]; //The index of the tree is the index into my data
vector
if (row < 0 and row >= size()) return 0; //make sure the vector is in
range
widget->label(label( row)); //label is a method of my data object to
return tab delim row - works fine
widget->w(0); // cause measure() to be called
widget->user_data((void*)row); //Do I really need this in this
implementation
if (data.at(row).selected)
widget->set_flag(fltk::SELECTED);
else
widget->clear_flag(fltk::SELECTED);
//no node is a parent in this implementataion
// if (false && data.at(row).open )
// widget->set_flag(fltk::STATE);
// else
widget->clear_flag(fltk::STATE);
return widget;
}
int BrowserList::children(const fltk::Menu*, const int* indexes, int level) {
//event_clicks(0);
if (!indexes) return -1; //? null indexes pointer
if (indexes[0] > data.size() -1 ) return -1; //past the end
if (indexes[1] > 0) return -1; // negative index
return data.size(); //data is an STL vector holding my data
}
void BrowserList::flags_changed(const Menu*, Widget* w){
//event_clicks(0) ;
Item *itm = (Item*)w;
unsigned int row = (unsigned int ) itm->user_data();
if (row < 0 or row >=data.size()) return;
data[row].selected = itm->selected();
data[row].open = false;
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk