简体   繁体   中英

New window not opening in fltk with button callback

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);

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM