I made a pop-up window for my application which is called ApplicationManager. It's a simple input dialog box which waits for user input for 10 secs. If no value entered, the pop-up closes. I already got this part working. Now I am struggling with the simpler part. When any data is entered in the input and OK is pressed, the dialog is supposed to close again. But at this->hide()
in handleCall
the GUI just hangs, even though the code proceeds further.
class Popup : public Fl_Window {
private:
Fl_Input *input;
Fl_Button *okBtn;
Fl_Button *cancelBtn;
std::string barcode;
void handleCall(Fl_Widget* w) {
Fl_Button *b = (Fl_Button*)w;
if(b->label() == "OK") {
barcode = input->value();
}
std::cout << b->label() << " " << input->value() << std::endl;
this->hide();
}
static void callBk(Fl_Widget* w, void* p){
Popup *pop = (Popup*)p;
pop->handleCall(w);
}
public:
Popup() : Fl_Window(400,120, "Manual Barcode") {
Fl_Input *label = new Fl_Input(250, 25, 0, 0, "Enter Barcode Manually");
input = new Fl_Input(75, 45, 300, 25);
okBtn = new Fl_Button(235, 85, 50, 25, "OK");
okBtn->callback((Fl_Callback*)callBk, this);
cancelBtn = new Fl_Button(300, 85, 75, 25, "Cancel");
cancelBtn->callback((Fl_Callback*)callBk, this);
end();
barcode = "";
}
void pop() {
std::cout << "showing popup" << std::endl;
//Fl::add_timeout(12, hidePopup, (void*)this);
this->show();
}
};