Windows: Mnemonics Issue
Abhinay Agarwal
abhinay_agarwal at live.com
Thu Jan 30 16:36:36 UTC 2020
On Windows, mnemonics is activated when ALT is pressed. This is true for apps made in JavaFX.
However I have found the following discrepancy between Windows Native Apps and JavaFX apps:
In Windows, pressing any key(not assigned to mnemonics) in combination with ALT doesn't de-activates mnemonics. It is automatically deactivated
when ALT is released. This can be reproduced in Notepad.
However in JavaFX, pressing ALT activates mnemonics. If any key (not assinged to mnemonics) is pressed while ALT is being pressed, it deactivates mnemonics. This can lead to an unwanted state.
This can be tested by the following steps:
1. Open Notepad -> Type ALT + A. Nothing happens. Once ALT is released, mnemonics is de-activated on the MenuBar.
2. Run the attached JavaFX sample. Press ALT -> mnemonics activated. Press 'ALT + A' -> mnemonics activates and then de-activates.
If you continue tapping 'A' (with ALT pressed), we can see that mnemonics are activated and deactivated. If we leave the mnemonics in activated state and try to
enter text 'F' in textfield, it will show the MenuItem(s) in the 'File' Menu.
Sample
=======
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
public class MenuBarMnemonics extends Application {
@Override
public void start(Stage primaryStage) {
BorderPane root = new BorderPane();
MenuBar b = new MenuBar();
Menu file = new Menu("_File");
MenuItem fileTest = new MenuItem("Tes_t");
file.getItems().add(fileTest);
b.getMenus().add(file);
Menu edit = new Menu("_Edit");
MenuItem editTest = new MenuItem("Te_st");
edit.getItems().add(editTest);
b.getMenus().add(edit);
root.setTop(b);
root.setCenter(new TextField());
Scene scene = new Scene(root,400,400);
primaryStage.setScene(scene);
primaryStage.show();
}
}
More information about the openjfx-dev
mailing list