Mnemonic Parsing doesn't appear to work properly
Scott Palmer
swpalmer at gmail.com
Fri Oct 29 17:53:46 UTC 2021
I looked in the bug database and while there are lots of bugs reported
against the mnemonic parsing, they claim to be fixed.
After noticing something peculiar on a control in my app (it was showing a
file path and I hadn't disabled the mnemonic parsing) I did some tests.
The documentation is unclear on what should happen if multiple underscores
are in the text. It just says if the mnemonic parsing character '_'
appears that the key combination will be based on the succeeding
character. I presume that it should pick only ONE of the underscores and
subsequent character, either the first or the last would make sense.
However, the behavior is that an unrelated character is shown as the
mnemonic and even it doesn't actually do anything. Tested with JDK 17.0.1
and JavaFX 17.0.1.
Does this behave as expected for you?
package mnemonic_parsing_bug;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Label titleLabel = new Label("""
The CheckBox below has text set to 'How_to_Test_Mnemonics'.
On Windows press the Alt key to see where the underlined
character appears.
It shows under the 'e' in Mnemonics for me, and I can't figure
out
what key combination (if any) actually does something.
[JavaFX Version %s]""".formatted(System.getProperty(
"javafx.version")) );
titleLabel.setMnemonicParsing(false);
CheckBox mnemonicCB = new CheckBox("How_to_Test_Mnemonics");
mnemonicCB.setMnemonicParsing(true);
VBox box = new VBox(8,titleLabel, mnemonicCB);
box.setPadding(new Insets(16));
Scene scene = new Scene(box);
primaryStage.setTitle("Mnemonic Parsing Bug");
primaryStage.setScene(scene);
primaryStage.show();
}
}
More information about the openjfx-dev
mailing list