-2

I created a button that when clicked on will open a new window through callback but when this button is clicked nothing happens but when it is released it blinks the new window and does not allow me to see the content in the new window. Please any help would be appreciated.

The callback

//Callback for advanced search
static void ad_cb(Fl_Button *theButton, void*)
{
    Fl_Window adw (10,10,600,400);
    Fl_Button  adcc (30,40,120,20,"Advanced Search");
    adcc.tooltip ("Make advanced search");
    adw.show();


}

The Button

Fl_Button  ad (30,460 + 40,120,20,"Advanced Search");
    ad.tooltip ("Make advanced search");
    ad.callback((Fl_Callback*)ad_cb);
Maxfurry
  • 54
  • 9

1 Answers1

1

The destructor is called as soon as the function exits. That is why you just see a flash. Change it to

//Callback for advanced search
static void ad_cb(Fl_Button *theButton, void*)
{
    Fl_Window* adw = new Fl_Window (10,10,600,400);
    Fl_Button*  adcc = new Fl_Button (30,40,120,20,"Advanced Search");
    adcc->tooltip ("Make advanced search");
    adw->show();
}

You can close the window by hitting the x in the top corner.

cup
  • 7,589
  • 4
  • 19
  • 42
  • Thank you so much for ur answer it solved my problem but please I would like to make the main window not work until the window called by the button is closed – Maxfurry Jan 25 '17 at 09:50
  • Make it modal - see http://stackoverflow.com/questions/25805938/create-custom-fltk-dialog-modal-window – cup Jan 25 '17 at 11:45