The answer to this is probably obvious, but I'm stumped.

When the program below starts up, the output window is
empty. Because of the line brw->select(1), line "One"
of the browser is highlighted on the screen.  So far, so good.

When the user clicks in the browser, the selection is
copied to the output box.  That's fine too.

When the button is pressed, the item in the output
is located in the browser, and is supposed to be
highlighted by the brw->select(i) call.  But its not
happening.

Any ideas would be appreciated.

-Stan



#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Select_Browser.H>
#include <FL/Fl_Output.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#include <cstring>

Fl_Output* out;
Fl_Button* btn;
Fl_Select_Browser* brw;

// Put selected browser item into output
void brw_cb(Fl_Widget*, void*)
{
  int v = brw->value();
  if(v) { out->value(brw->text(v)); }
}

// Find contents of output in
// browser and select it
void btn_cb(Fl_Widget*, void*)
{
  char const* v = out->value();
  if(v) {
    for(int i = 1; i <= brw->size(); ++i) {
      if(!std::strcmp(brw->text(i), v)) {
        brw->select(i);   // This seems to have no effect
      }
    }
  }
}
int main()
{
  Fl_Double_Window win(300, 300, "Window");
  out = new Fl_Output(100, 100, 80, 20, "Output");
  btn = new Fl_Button(180, 100, 20, 20, "x");
  brw = new Fl_Select_Browser(100, 120, 100, 100);
  win.end();
  btn->callback(btn_cb);
  brw->callback(brw_cb);
  brw->add("One");
  brw->add("Two");
  brw->add("Three");
  brw->add("Four");
  brw->select(1);  // This causes "One" to be highlighted initially
  win.show();
  return Fl::run();
}



_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to