> I am trying to create a menu-like window which pops up when the user
> interacts with a search field in a modal window. I have created an
> example which you should be able to compile after copy & paste (if the
> mail client doesn't break the lines). What I need help with is how to
> get the green window behave like a modal one (as far as not letting the
> main window with the "Click me" button work), but let the button in the
> search popup work.
Here is my proposal :)
class SearchPopup : public Fl_Double_Window {
private:
Fl_Double_Window* wparent;
public:
SearchPopup(int X, int Y, Fl_Double_Window* wp) : Fl_Double_Window(X, Y,
300, 180), wparent(wp) {
color(FL_YELLOW);
border(0);
set_non_modal(); // not modal !
Fl_Button* aButton = new Fl_Button(100, 50, 50, 50, "How can
I make this button work\n(And the the input field in the\ngreen window
at the same time)?");
aButton->align(FL_ALIGN_TOP);
end();
}
int handle(int event) {
switch(event) {
case FL_KEYUP: // make sure FL_KEYUP does not go to wparent
case FL_PUSH:
case FL_RELEASE:
int ret = Fl_Double_Window::handle(event);
wparent->take_focus(); // so Fl_Input can receive events
return ret;
}
return Fl_Double_Window::handle(event);
}
};
class SearchWindow : public Fl_Double_Window {
private:
Fl_Input* myInput;
SearchPopup* mySearchPopup;
int xoff, yoff;
public:
SearchWindow(int X, int Y) : Fl_Double_Window(X, Y, 300, 180) {
border(0);
color(FL_GREEN);
set_non_modal(); // non modal !
myInput = new Fl_Input(50, 50, 200, 30, "Enter text to open a result
window");
myInput->callback(staticInputCB, (void*)this);
myInput->when(FL_WHEN_CHANGED);
myInput->align(FL_ALIGN_TOP_LEFT);
end();
mySearchPopup = new SearchPopup(300, 300, this);
mySearchPopup->end();
}
// rest of the code is the same...
--
Sanel
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk