1. ControlsFX
  2. ControlsFX
  3. ControlsFX
  4. Issues

Issues

Issue #736 new

ComboBox Autocomplete triggers upon selecting entries from dropdown list, not just typing

Peter Trefonas
created an issue

This is irritating and shouldn't happen. Autocomplete should only trigger when typing, not when using the mouse or arrow keys to select an entry from a combo list.

Using it like this: myCombo.setEditable(true); TextFields.bindAutoCompletion(myCombo.getEditor(), myCombo.getItems());

Comments (7)

  1. Peter Trefonas reporter

    Hey Samir,

    Sorry for not including a coding example! I was considering the most basic scenario. Here is an example showing the issue.

    So in this example, if you type "O" or "option" all three options appear and can be selected properly. If you type "2", only "Option 2" appears. This is good. If you use the mouse or arrow keys to select an option after pressing the little down arrow on the right side of a combo box, an additional drop down list appears, even though you have already selected from the list of options. This is bad.

    import javafx.collections.ObservableList;
    import javafx.collections.FXCollections;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.layout.Pane;
    import javafx.scene.control.ComboBox;
    import javafx.stage.Stage;
    import org.controlsfx.control.textfield.TextFields;
    
    public class App extends Application {
      public static void main(String[] args) {
        launch(args);
      }
    
      @Override
      public void start(Stage stage) throws Exception {
        ComboBox<String> myCombo = new ComboBox<String>();
        ObservableList<String> options = 
          FXCollections.observableArrayList("Option 1","Option 2","Option 3");
        myCombo.setItems(options);
        myCombo.setEditable(true);
        TextFields.bindAutoCompletion(myCombo.getEditor(), myCombo.getItems());
        stage.setScene(new Scene(new Pane(myCombo)));
        stage.setMinWidth(200);
        stage.setMinHeight(200);
        stage.show();
      }
    }
    
  2. Samir Hadzic

    Allright, thanks.

    The problem must come from the fact that we do not see we already selected something and we must not show the drop down list. I'll investigate. If you have any ideas on how to fix that, don't hesitate to submit a pull request or some code in here.

  3. Md.Al-Helal

    Thank you , Peter Trefonas. Your code helped me to starting with controlfx auto completion combobox. I have expended many time for auto completion combox. Finally I got the solution.

  4. Kristian Kongsted

    Hi, is this someting you are already looking into? How is the procedure if I would like to fix it myself and do a PR? I am sure you have a document I should read somewhere :). I guess I can just clone the repo and do a PR, always rebasing and single commits?

  5. Log in to comment