On 11.01.2013 14:27, Denton Thomas wrote: > I am trying to create a little widget/group made of an Fl_Input (or text > editor) and a drop-down-menu-like suggestions box. The end goal is to make > something similar to an AJAX-y suggestions box found on google, or the > firefox sites suggestions, etc. > > It's easy for me to create/fill/show a popup made of an Fl_Select_Browser > inside an Fl_Menu_Window. If I use an Fl_Menu_Window, though, show() steals > focus and the mouse cursor from my Fl_Input widget. I can't send back focus > because the menu is a new window ... or at least I haven't figured out how to > send it back ... ?
As Ian wrote, I'm also not sure if Fl_Menu_Window is the best solution, but maybe this doesn't matter. I solved a similar, but different issue, and the best I can do is to describe what I've done to solve it. My problem was similar to FLTK's Fl_Choice widget. I have an input widget and another box (the usual one with the small triangle used to open that "suggestion" window). The user must click on the triangle box to open the "suggestion" window. My window is derived from Fl_Double_Window, but I also use set_override() to make it borderless, like Fl_Menu_Window. That's why I think that the window type wouldn't matter. Additionally I use Fl::grab() to make the suggestion/menu window take all events when it is opened. That's like a menu window, and "steals focus" from the input widget as you describe with your solution. But then, well, why would you need to give the focus back to the input widget? You don't need to do that if your handle() method of the window or its embedded browser widget has the focus (see Fl::grab()) and handles the input. It's some work, but you can do everything you like ... Add one character at a time to your input widget and update the browser widget whenever a key is pressed (FL_KEYBOARD event), put the selected value into the input widget's value() whenever a browser item is selected, and so on. The only problem I see with this approach is that the input widget indeed doesn't have the focus, and thus doesn't give much visible feedback like a cursor to show the current point of input. You may want to derive your own input class as well and make your own draw() method to show a cursor if you go that route. Maybe... Albrecht _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk