-
Bug
-
Resolution: Fixed
-
P3
-
fx2.1
If I use Mnemonics for my Controls, the action event of that control is still fired, when I use that mnemonic (keyboard input), although the control is disabled.
As a developer, if I disable my controls, I don't want the user to be able to use that control, no matter if by mouse or by keyboard. The action event should not fire on disabled controls.
Here is a sample (e.g. press ALT + T and see that output is still written).
This is probably an issue in javafx.scene.control.Labeled base class.
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TestApp3 extends Application {
public static void main(String[] args) throws Exception {
launch();
}
public void start(final Stage stage) throws Exception {
VBox root = new VBox();
Button button = new Button("_Test");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("Button action");
}
});
button.setDisable(true);
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("_Menu");
MenuItem item = new MenuItem("_Item");
item.setDisable(true);
item.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("Item activated");
}
});
menu.getItems().add(item);
menuBar.getMenus().add(menu);
root.getChildren().add(menuBar);
root.getChildren().add(button);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
As a developer, if I disable my controls, I don't want the user to be able to use that control, no matter if by mouse or by keyboard. The action event should not fire on disabled controls.
Here is a sample (e.g. press ALT + T and see that output is still written).
This is probably an issue in javafx.scene.control.Labeled base class.
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TestApp3 extends Application {
public static void main(String[] args) throws Exception {
launch();
}
public void start(final Stage stage) throws Exception {
VBox root = new VBox();
Button button = new Button("_Test");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("Button action");
}
});
button.setDisable(true);
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("_Menu");
MenuItem item = new MenuItem("_Item");
item.setDisable(true);
item.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("Item activated");
}
});
menu.getItems().add(item);
menuBar.getMenus().add(menu);
root.getChildren().add(menuBar);
root.getChildren().add(button);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
- blocks
-
JDK-8094301 Scene Builder menus should have mnemonics
- Resolved