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

ComboBox drag start issues (not fired, fired twice)

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7u40
    • Fix Version/s: tbd
    • Component/s: javafx

      Description

      setOnDragDetect(...) on ComboBox doesn't work the way one would expect when the ComboBox is editable.

      If you do setOnDragDetect on the ComboBox - the drag event will not be fired when the user drags from the text editor area of the combo box. It only fires if they drag from the far right arrow.

      Instead, if you setOnDragDetect on the ComboBox editor component - then when the drag begins from the editor area, the drag event is fired twice. If the drag begins from the right arrow, it is only fired once, as expected.

      Test app:

      import javafx.application.Application;
      import javafx.event.Event;
      import javafx.event.EventHandler;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.stage.Stage;

      public class FileOpenBug extends Application
      {
      public static void main(String[] args)
      {
      launch(args);
      }

      @Override
      public void start(final Stage primaryStage)
      {
      primaryStage.setTitle("bug");
      Group root = new Group();

      ComboBox<String> cb = new ComboBox<>();
      cb.getItems().add("Test Item ");
      cb.setEditable(true);
      cb.getSelectionModel().selectFirst();

      //This doesn't work - only allows drag from the right arrow - drag from the text field doesn't work.
      //cb.setOnDragDetected(new EventHandler<Event>()

      //This works - but drag gets fired twice
      cb.getEditor().setOnDragDetected(new EventHandler<Event>()
      {
      @Override
      public void handle(Event event)
      {
      System.out.println("drag");
      }
      });

      root.getChildren().add(cb);
      primaryStage.setScene(new Scene(root, 500, 400));
      primaryStage.show();
      }
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              vortexjfx vortex (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Imported: