4

I've added Mnemonics to a menu bar using JavaFX 2.2 and Scene Builder, but it doesn't work 100% well.

This is my menu:

enter image description here

When I press Alt, it looks like this, which is correct:

enter image description here

Then I press "D", and the menu opens, but the Mnemonics inside the menu are not underlined:

enter image description here

The lines do appear when I press Alt again; however, then the line under the "D" of "Datei" disappears:

enter image description here

So it seems to be some kind of buggy toggling function in JavaFX.

Anyway, I want the Mnemonics to be underlined all at once, just like when I click the menu:

enter image description here


When you click the menus with the mouse and then press Alt all Mnemonics are correctly underlined at once. Pressing Alt again will toggle between underlined and not underlined. This is the normal, expected behavior.

So I think when opening a menu via Mnemonics, the Oracle guys just forgot to call some kind of "underlineMnemonics()" method for the submenu. Does anybody know what method that is, so I can call it myself when opening a menu? Or does anyone have another workaround?

For example, I know that you can make the underlines of the main menu bar visible via CSS:

    .mnemonic-underline {
            -fx-stroke: -fx-text-base-color;
    }

But I failed to make this work on the submenus. (Also, this would not be an ideal solution, because this way the underlines couldn't be toggled off again.)

Ginchen
  • 790
  • 7
  • 20
  • 1
    By now I found out that this has been fixed in JavaFX 8. (Source: https://javafx-jira.kenai.com/browse/RT-25539) But like the majority of JavaFX 2 bugs, the fix probably won't be backported to 2.x. So any workarounds are still welcome! – Ginchen Feb 23 '14 at 13:26
  • I dont think its fixed in JavaFx8 as I have exactly the same issue in 8.0.202 aswell – Ashok Koyi Jun 17 '19 at 14:54

0 Answers0