Search code examples
fltk

Remove Underline under FLTK Menu Options


I'm creating a MenuBar in FLTK, and can't figure out how to remove the little underlines under each menu category. What setting controls this?

enter image description here


Solution

  • When you specify the labels of menu's entries, you have to remove &: see the examples below.

    With &:

    #include <FL/Fl.H>
    #include <FL/Fl_Double_Window.H>
    #include <iostream>
    #include <FL/Fl_Menu_Bar.H>
    int main() {
        Fl_Double_Window* G_win = new Fl_Double_Window(200,200);
        Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25);
        
        menu->add("&File"); // F is underlined
        menu->add("Edi&t"); // t is underlined
    
        G_win->show();
        return(Fl::run());
    }
    

    Without &:

    #include <FL/Fl.H>
    #include <FL/Fl_Double_Window.H>
    #include <iostream>
    #include <FL/Fl_Menu_Bar.H>
    int main() {
        Fl_Double_Window* G_win = new Fl_Double_Window(200,200);
        Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25);
        
        menu->add("File"); // No letter is underlined
        menu->add("Edit"); // No letter is underlined
    
        G_win->show();
        return(Fl::run());
    }
    

    In the last case, the label of each menu does not have any underlined letter. See here for a more detailed explanation.