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

[TextField] Right-click opens both popup and context menu.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8
    • javafx
    • jdk 1.8.0 - b62

      To reproduce:

      1. Right-click on the textfield;
      2. Pop-up and context menu will both appear.


      import javafx.application.Application;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.ContextMenu;
      import javafx.scene.control.MenuItem;
      import javafx.scene.control.TextField;
      import javafx.scene.input.ContextMenuEvent;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class BugTextFieldContextMenu extends Application {

          TextField testedControl;

          @Override
          public void start(Stage stage) {

              testedControl = new TextField("Quick brown fox jumps over lazy unicorn");

              final ContextMenu contextMenu = new ContextMenu();
              for (int i = 0; i < 3; i++) {
                  contextMenu.getItems().add(new MenuItem("Menu item - " + i));
              }

              testedControl.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
                  @Override
                  public void handle(ContextMenuEvent t) {
                      contextMenu.show(testedControl, t.getScreenX(), t.getScreenY());
                  }
              });

              HBox root = new HBox(20d);
              root.getChildren().add(testedControl);

              Scene scene = new Scene(root, 300, 250);

              stage.setScene(scene);
              stage.setTitle(System.getProperty("java.runtime.version") + "; " + System.getProperty("javafx.runtime.version"));
              stage.show();
          }

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

            leifs Leif Samuelsson (Inactive)
            dzinkevi Dmitry Zinkevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: