Here's a (minimal) implementation of my problem. When I click the lower button, 
fl_alert() appears and suddenly closes as if a mouse click was still pending.
I use FLTK 1.1.9 with CodeBlocks (MinGW)and WinXP.

*********************************************************************
#include <cstdio>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <Fl/Fl_Toggle_button.H>
#include <Fl/Fl_Message.H>


class MyWin : public Fl_Window {
   public:
      MyWin();
      int handle(int e);
   private :
      static void exit_cb(Fl_Widget* w, void *p);
      Fl_Toggle_Button* Btnum[10];
      Fl_Button* Btnumok;
};

MyWin::MyWin() : Fl_Window(400, 180, 118, 125) {
   char s[3];
   for (int c = 0; c < 9; c++) {
      Btnum[c] = new Fl_Toggle_Button (10+34*(c%3), 2+32*(c/3), 30, 30);
      sprintf(s, "%d", c+1);
      Btnum[c]->copy_label(s);
   }
   Btnumok =  new Fl_Button(10, 100, 46, 20, "Ok");
   Btnumok->callback(exit_cb);
   end();
   set_modal();
   show();
}

int MyWin::handle (int event) {
   int ret = Fl_Window::handle(event);
   if (event == FL_PUSH) {
      int num = find(Fl::pushed());
      if (num > 8) return 1;        // OK was pressed
        // else do something
   }
   return ret;
}

void MyWin::exit_cb(Fl_Widget* w, void* p) {
    // do something
    w->window()->hide();
}

//**************************************************************************************

class MyBox : public Fl_Box {
   public:
      MyBox(int x, int y, int w, int h, char* l) : Fl_Box(x, y, w, h, l) 
{box(FL_UP_BOX); }
   protected :
      int handle(int event);
};

int MyBox::handle (int event) {
   if (event == FL_PUSH) {
      MyWin* MW = new MyWin();
      label ("Click numbers and then OK");
      while (MW->shown()) Fl::wait();
      delete MW;
      return 1;
   }
   return Fl_Box::handle(event);
}

//**************************************************************************************

void showalert_cb(Fl_Widget* w, void* p) {
    fl_alert("This disappears!");
}

int main (int argc, char ** argv) {
  Fl_Window *window;
  Fl_Button *w;

  window = new Fl_Window (300, 180);
  new MyBox (20, 40, 200, 30, "First click here");
  w = new Fl_Button(20, 100, 100, 30, "Then here");
  w->callback(showalert_cb);
  window->show();
  return(Fl::run());
}

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

Reply via email to