Hi All,
I think I've discovered a bug in Fl_Sys_Menu_Bar for MacOS.
Basically if I assign a menu item a shortcut FL_ALT+'u', the use of that shortcut appears to "block" other shortcuts in the menu bar.
I proved minimal working code demonstrating the bug below. In this case command+f or command+g work as expected until I use the shortcut alt+u after which the previous two commands stop working.
This, however *doesn't* affect an identically defined shortcut FL_COMMAND+'i' so it appears to be contingent on the precise shortcut.
If I then navigate to the menu bar with the mouse the shortcuts "reactivate" and respond normally again.
Other key points:
1. If I replace alt+'u' with alt+'t' this bug doesn't manifest
2. This only happens with Fl_Sys_Menu_Bar on Mac. Using Fl_Menu_Bar on mac does not exhibit this bug.
This has been tested on MacOS 11.6 using both FLTK 1.3.7 and 1.4.x
Code:
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Sys_Menu_Bar.H>
#include <stdio.h>
#include <iostream>
void ctrlf(Fl_Widget *, void *) {
std::cout<<"in cmd f"<<std::endl;
}
void ctrlg(Fl_Widget *, void *) {
std::cout<<"in cmd g"<<std::endl;
}
void ctrli(Fl_Widget *, void *) {
std::cout<<"in cmd i"<<std::endl;
}
void altu(Fl_Widget *, void *) {
std::cout<<"in alt u"<<std::endl;
}
int main() {
Fl_Double_Window *win = new Fl_Double_Window(Fl::w() / 2 - 200, Fl::h() / 2 - 200, 400, 400, "Main Win");
Fl_Menu_Item items[] = {
{"Menu1", 0, 0, 0, FL_SUBMENU, 0, 0, FL_NORMAL_SIZE, FL_BLACK}, // 0
{"cmd f", FL_COMMAND + 'f', ctrlf, NULL, 0, 0, 0, FL_NORMAL_SIZE, FL_BLACK},
{"cmd g", FL_COMMAND + 'g', ctrlg, NULL, 0, 0, 0, FL_NORMAL_SIZE, FL_BLACK},
{"cmd i", FL_COMMAND + 'i', ctrli, NULL, 0, 0, 0, FL_NORMAL_SIZE, FL_BLACK},
{"alt u", FL_ALT + 'u', altu, NULL, 0, 0, 0, FL_NORMAL_SIZE, FL_BLACK},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0}};
Fl_Sys_Menu_Bar *menu = new Fl_Sys_Menu_Bar(0, 0, win->w(), 25);
menu->menu(items);
win->end();
win->show();
return Fl::run();
}
Thanks,
R.