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

TableView: CTRL-mouse click does not select the item on OS X in single cell selection mode

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 7u10
    • Fix Version/s: 8u60
    • Component/s: javafx
    • Labels:
    • Environment:

      OS X, b12

      Description

      CTRL-mouse click does not select the item on OS X in single cell selection mode.

      Sample:
      import java.util.ArrayList;
      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.value.ObservableValue;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableColumn.CellDataFeatures;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.util.Callback;
      import javafx.scene.control.TableView;

      public class Main extends Application {
          final static int ROWS_NUM = 30;
          final static int COLUMNS_NUM = 20;

          @Override
          public void start(Stage stage) {
              VBox content = new VBox();
              ObservableList<Data> data = FXCollections.<Data>observableArrayList();
              for (int i = 0; i < ROWS_NUM; i++) {
                  data.add(new Data(i, COLUMNS_NUM));
              }
              final TableView view = new TableView();
              view.setMinSize(400, 399);
              view.setMaxSize(400, 399);
              view.setPrefSize(400, 399);
              VBox.setVgrow(view, Priority.ALWAYS);
              ArrayList <TableColumn<Data, String>> fields = new ArrayList <TableColumn<Data, String>>();
              for (int i = 0; i < COLUMNS_NUM; i++) {
                  final int index = i;
                  TableColumn<Data, String> field = new TableColumn<Data, String>("field " + i);
                  fields.add(field);
                  field.setCellValueFactory(new Callback<CellDataFeatures<Data, String>, ObservableValue<String>>() {
                      public ObservableValue<String> call(CellDataFeatures<Data, String> p) {
                          return new SimpleStringProperty(((Data)p.getValue()).data.get(index));
                      }
                  });
              }
              view.getColumns().addAll(fields);
              view.setItems(data);
              view.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
              view.getSelectionModel().setCellSelectionEnabled(true);
              content.getChildren().add(view);

              Scene scene = new Scene(content, 400, 400);

              stage.setScene(scene);
              stage.show();
          }

          public static class Data {
              public ArrayList<String> data = new ArrayList<String>();
              public Data(int column_num, int fields_num) {
                  for (int i = 0; i < fields_num; i++) {
                      data.add("item " + column_num + " field " + i);
                  }
              }
          }

          public static void main(String[] args) {
              Application.launch(Main.class, args);
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jgiles Jonathan Giles
              Reporter:
              ogb Oleg Barbashov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: