> On 04/25/12 07:10, leowang wrote: > >>> I found that after the browser widget created, it is focused in the first > >>> line, but the first line does not highlight, how to set it to highlight, I > >>> tryed select(0, true), but has no effect. > >> > >> You might find that browser lines are numbered from 1, not from 0, IIRC, > >> th= > >> ough you should check the docs in case I am remembering incorrectly. > > > > I have note it , but even I call select(1, true), it still has > > no highlight in the first line. > > Works for me: > > #include <FL/Fl.H> > #include <FL/Fl_Window.H> > #include <FL/Fl_Browser.H> > #include <FL/Fl_Button.H> > void select_cb(Fl_Widget*w,void*data) { > Fl_Browser *b = (Fl_Browser*)data; > if ( w->label()[0] == 'O' ) { b->select(1,1); } // one > if ( w->label()[0] == 'T' ) { b->select(2,1); } // two > } > int main() { > Fl_Window win(300,450); > Fl_Browser brow(10,10,300-20,450-60); > brow.add("one"); > brow.add("two"); > brow.add("three"); > brow.add("four"); > Fl_Button b1(10 ,450-30,140,25,"One Select"); > b1.callback(select_cb, (void*)&brow); > Fl_Button b2(160,450-30,140,25,"Two Select"); > b2.callback(select_cb, (void*)&brow); > win.end(); > win.show(); > return(Fl::run()); > }
Thanks, now it also works for me, I have a mistake when I write code, it should call select(1, true) after add() function, but I called it before add item in browser. Thanks all. Best regards, Leo _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk