瀏覽代碼

Update combobox docs to use setNewItemProvider (#10901)

tags/8.5.0.alpha2
Anastasia Smirnova 6 年之前
父節點
當前提交
3e82a2b548
共有 1 個檔案被更改,包括 3 行新增4 行删除
  1. 3
    4
      documentation/components/components-combobox.asciidoc

+ 3
- 4
documentation/components/components-combobox.asciidoc 查看文件

@@ -52,7 +52,7 @@ attempt to do so may result in an exception.

=== 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.


@@ -73,7 +73,7 @@ select.setItemCaptionGenerator(Planet::getName);

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

Planet newPlanet = new Planet(planets.size(), inputString);
planets.add(newPlanet);
@@ -81,8 +81,7 @@ select.setNewItemHandler(inputString -> {
// Update combobox content
select.setItems(planets);

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


Loading…
取消
儲存