CheckComboBox focus inconsistent with the rest of java controls

Issue #740 new
Radu Stefan Popescu
created an issue

Clicking on the ChekComboBox doesn't set focus on it, nor does clicking in the dropdown list.

This is inconsistent when compared to normal ComboBox and pretty much every other control in JavaFX.

This is a serious issue when you're trying to tie any logic to the focus value. E.g. in a virtualized control where you want to commit the changes at certain points in time instead of always tracking them with one of the ObservableList listeners on the checkModel.

Here is an example where the CheckComboBox receives focus only once, because it is the first item in the root node. Next to it is a JavaFX ComboBox as a reference in focus behaviour. When clicking on the root node focus is switched to the rood node.

    private final ObservableList<String> strings = FXCollections.observableArrayList();
    private CheckComboBox<String> checkComboBox = new CheckComboBox<>(strings);
    private ComboBox<String> comboBox = new ComboBox<>();

    @Override
    public void start(Stage primaryStage) throws Exception {
        for(int i = 0; i<=100;i++){
            strings.add("Item "+ i);
        }
        comboBox.setItems(strings);


        VBox root = new VBox(5);
        root.getChildren().addAll(checkComboBox,comboBox);
        Scene scene = new Scene(root,800,600);

        checkComboBox.focusedProperty().addListener((observable, oldValue, newValue) -> System.out.println("CheckComboBox focused: "+newValue));
        comboBox.focusedProperty().addListener((observable, oldValue, newValue) -> System.out.println("ComboBox focused:" + newValue));
        root.setOnMousePressed(event -> root.requestFocus());

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

Comments (0)

  1. Log in to comment