-
Bug
-
Resolution: Fixed
-
P5
-
8u25, 9, 10
-
Windows 7
This is a minor, and 100% cosmetic issue, but the Devil is in the details..
When you add a disabled MenuItem into a ContextMenu, everything is as expected.
When you add a disabled Menu into a ContextMenu, the disabled Menu never appears to receive mouse over events, and a bit confusingly, the MenuItems next to this disabled menu continue to have "mouse over effect", even if the disabled Menu is actually hovered.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;
public class MenuTest extends Application {
@Override
public void start(Stage stage) throws Exception {
Label root = new Label();
ContextMenu menu = new ContextMenu();
menu.getItems().add(new MenuItem("MenuItem 1"));
menu.getItems().add(new Menu("Menu 1"));
menu.getItems().add(new MenuItem("MenuItem 2"));
menu.getItems().add(new MenuItem("MenuItem 3"));
menu.getItems().add(new MenuItem("MenuItem 4"));
menu.getItems().get(1).setDisable(true);
menu.getItems().get(4).setDisable(true);
root.setContextMenu(menu);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
MenuTest.launch(args);
}
}
When you add a disabled MenuItem into a ContextMenu, everything is as expected.
When you add a disabled Menu into a ContextMenu, the disabled Menu never appears to receive mouse over events, and a bit confusingly, the MenuItems next to this disabled menu continue to have "mouse over effect", even if the disabled Menu is actually hovered.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;
public class MenuTest extends Application {
@Override
public void start(Stage stage) throws Exception {
Label root = new Label();
ContextMenu menu = new ContextMenu();
menu.getItems().add(new MenuItem("MenuItem 1"));
menu.getItems().add(new Menu("Menu 1"));
menu.getItems().add(new MenuItem("MenuItem 2"));
menu.getItems().add(new MenuItem("MenuItem 3"));
menu.getItems().add(new MenuItem("MenuItem 4"));
menu.getItems().get(1).setDisable(true);
menu.getItems().get(4).setDisable(true);
root.setContextMenu(menu);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
MenuTest.launch(args);
}
}