Making shortcuts in menus work when the menubar is hidden

6 views
Skip to first unread message

Gonzalo Garramuño

unread,
Apr 10, 2023, 12:13:52 PM4/10/23
to fltkg...@googlegroups.com
In my viewer, I have a number of hotkeys set in the menu bar's different
menus.  These work fine as long as the menu bar is visible.

However, I also allow the user to hide the menu bar.  When I do that,
the shortcuts in the menus stop working.

Can someone offer a work-around?  I don't want to litter my viewer's
main window's handle(FL_KEYBOARD) with the same hotkeys and functions of
the menu bar.

Gonzalo Garramuño

unread,
Apr 10, 2023, 12:49:16 PM4/10/23
to fltkg...@googlegroups.com

El 10/4/23 a las 13:13, Gonzalo Garramuño escribió:
Ok.  I think I solved it.  I subclassed Fl_Menu_Bar and in my view
window and I sent out a FL_SHORTCUT message when the menu bar was
hidden. My MenuBar does:



    int MenuBar::handle(int event) {
        const Fl_Menu_Item* v;
        switch (event) {
        case FL_SHORTCUT:
            v = menu()->find_shortcut(0, true);
            if (v && v->submenu())
            {
                v = menu()->pulldown(x(), y(), w(), h(), v, this, 0, 1);
                picked(v);
                return 1;
            }
            return test_shortcut() != 0;
        default:
            return Fl_Menu_Bar::handle(event);
        }
        return 0;
    }



Reply all
Reply to author
Forward
0 new messages