Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8168437

ContextMenu: selection mark issue

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9
    • javafx
    • None
    • b141

      First item gets the selection mark is at the first invocation of show() method (and there is no selection mark at the second invocation).

      Sample to check:

      import javafx.application.Application;
      import javafx.event.EventHandler;
      import javafx.geometry.Side;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.input.MouseEvent;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class App extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage stage) throws Exception {
              ContextMenu control = new ContextMenu();
              for (int i = 0; i < 3; i++) {
                  control.getItems().add(new MenuItem("Item " + i));
              }
              
              Label menu_label = new Label("Menu");
              menu_label.setOnMouseReleased(new EventHandler<MouseEvent>() {
                  public void handle(MouseEvent t) {
                      if (control.isShowing()) {
                          control.hide();
                      } else {
                          control.show(menu_label, Side.BOTTOM, 0, 0);
                      }
                  }
              });

              Scene scene = new Scene(new HBox(menu_label));
              stage.setScene(scene);
              stage.show();
          }
      }

            Unassigned Unassigned
            ogb Oleg Barbashov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: