On 21 Jan 2013, at 17:39, Howard Rubin wrote:

> How can I get a menu item to drop down by hovering the mouse?
> 
> In this program, clicking on the File menu will drop it down, and then I 
> can just move the mouse over the Edit menu to drop it down.
> 
> I need the File menu to drop down when I move the mouse over it without 
> the mouse click.
> 
> 
> #include <FL/Fl.H>
> #include <FL/Fl_Double_Window.H>
> #include <FL/Fl_Menu_Bar.H>
> 
> int main(int argc, char **argv) {
>     Fl_Double_Window *win = new Fl_Double_Window(300,100);
>     Fl_Menu_Bar *menubar = new Fl_Menu_Bar(0,0,300,25);
> 
>     menubar->add("&File/Open");
>     menubar->add("&File/Save");
> 
>     menubar->add("&Edit/Cut");
>     menubar->add("&Edit/Copy");
>     menubar->add("&Edit/Paste");
> 
>     win->end();
>     win->show();
> 
>     return(Fl::run());
> }


There's no built-in support for that in fltk, so you'll need to roll your own 
widget to do this.

For most widgets, the normal thing to do would be just derive from the widget 
you want to tweak, then override the handle() method to catch the enter/leave 
events and use those to trigger your drop down.

But... for historical reasons (possibly to be resolved in fltk3!) the 
Fl_Menu_Item widget is not a true class, and you can't really derive your own 
modified version as a result...

Instead, what you can do is replace the Fl_Menu_Bar with a simple box, 
populated with your own widgets derived from Fl_Menu_Button - this can easily 
be made to appear like a conventional menu bar, but the derived Fl_Menu_Button 
widgets can have a modified handle() method that catches the FL_ENTER / 
FL_LEAVE events and uses those events to trigger to popping up (or down) of the 
menu associated with the Fl_Menu_Button.

Any use...?



_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to