Browse Source

Update combobox docs to use setNewItemProvider (#10901)

tags/8.5.0.alpha2
Anastasia Smirnova 6 years ago
parent
commit
3e82a2b548
1 changed files with 3 additions and 4 deletions
  1. 3
    4
      documentation/components/components-combobox.asciidoc

+ 3
- 4
documentation/components/components-combobox.asciidoc View File



=== Handling New Items === Handling New Items


Adding new items is handled by a [interfacename]#NewItemHandler#, which gets the
Adding new items is handled by a [interfacename]#NewItemProvider#, which gets the
item caption string as parameter for the [methodname]#accept(String)# method. item caption string as parameter for the [methodname]#accept(String)# method.






// Allow adding new items and add // Allow adding new items and add
// handling for new items // handling for new items
select.setNewItemHandler(inputString -> {
select.setNewItemProvider(inputString -> {


Planet newPlanet = new Planet(planets.size(), inputString); Planet newPlanet = new Planet(planets.size(), inputString);
planets.add(newPlanet); planets.add(newPlanet);
// Update combobox content // Update combobox content
select.setItems(planets); select.setItems(planets);


// Remember to set the selection to the new item
select.setSelectedItem(newPlanet);
return Optional.of(newPlanet);
}); });
---- ----



Loading…
Cancel
Save