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

Issues

Issue #739 new

SearchableComboBox

Tobias Schulte
created an issue

I have created a Searchable ComboBox. It functions a bit like the combo boxes for Component and Milestone in the bitbucket "Create issue" page.

If you are interested, I would like to offer creating a pull request.

Comments (6)

  1. Samir Hadzic

    Hey Tobias,

    That seems very nice. What is the purpose of this Control? It's a mix between an editable ComboBox and a PrefixSelectionChoiceBox? Please sign the CLA and submit your pull request so that we can take a look at the code.

    We have a section in the samples regarding the TextFields with the autocomplete textFields, maybe your control could be in that section.. I don't know..

  2. Tobias Schulte reporter

    Currently the Control only works with editable=false and works by replacing the displayNode with the searchField, while the popup is showing.

    We have a lot of items in our ComboBoxes, sometimes all items start with the same char (e.g. Fzg0001 - Fzg9999). In that case the PrefixSelectionComboBox does not work (when the user just wants to type 9999). And the PrefixSelectionComboBox only work for fast typists. Slow typists would enter 'f' pause, 'z', pause, ... Another issue with the prefix selection is, that you don't see what is happening, and theh popup closes when typing.

    In our control, the entered text filters by testing if the item text contains all words in the search field (ignoring case). But the user must select one of the provided entries, therefore we can't use the editable ComboBox with AutoCompleting TextField.

    Also it only works for ComboBox, not ChoiceBox. But since the ChoiceBox is designed for only a few elements, a SearchableChoiceBox does not seem to make much sense.

    I need to update the code to also handle editable ComboBoxes to have it ready for a pull request, but wanted to make sure you would be interested before investing time in this.

  3. Samir Hadzic

    Allright I understand.

    Well, new contributions are always welcomed. If you had this specific scenario, maybe others will have it also and thus be interested in your Control. If you have some time to improve it and make a good API around it, we will gladly take it and merge it. But we will have to test it and make sure the API is good, that the documentation (Javadoc) is detailed, and it is robust.

    Having all these criterias in place could be quite time consuming but the community can help you with it. If you don't think you would have enough time, you can always paste some snippets here, and maybe someone will carry on your work some time in the future :)

  4. Tobias Schulte reporter

    Currently my implementation consists of a SearchableComboBoxListViewSkin<T> extends ComboBoxListViewSkin<T> and a SearchableComboBox<T> extends ComboBox<T> which only overrides createDefaultSkin to return the new skin. One could also set the skin using CSS though.

    There are some issues I see:

    • ComboBoxListViewSkin does not offer to override the Behavior. Therefore I implemented the behavior in the skin class (which is only 200 LOC though).
    • ComboBoxListViewSkin.createListView is private and sets the behavior when typing ENTER, ESC and SPACE using listView.setOnKeyPressed. I needed a different behavior, and since I also used setOnKeyPressed, it worked. I tried to later refactor this to .addEventHandler(KeyEvent.KEY_PRESSED,, but from that moment on, it did not work any more (I have TestFX tests that broke).

    I wanted to have most of the default implementation of the ComboBox and only enhance it a bit. But maybe this results in a more brittle implementation, because if the implementation of the (private API) ComboBoxListViewSkin changes only in some small detail, my implementation might break. But I don't want to implement the whole ComboBoxSkin again.

    Maybe it is best if I just create a pull request in it's current form and we can discuss there.

  5. Log in to comment