< prev index next >
modules/javafx.controls/src/main/java/javafx/scene/control/cell/TextFieldTreeCell.java
Print this page
rev 10463 : 8089514: [TableView, TreeView, ListView, TreeTableView] Clicking outside of the edited cell, node, or entry should commit the value
@@ -36,10 +36,12 @@
import javafx.scene.layout.HBox;
import javafx.util.Callback;
import javafx.util.StringConverter;
import javafx.util.converter.DefaultStringConverter;
+import java.util.Optional;
+
/**
* A class containing a {@link TreeCell} implementation that draws a
* {@link TextField} node inside the cell.
*
* <p>By default, the TextFieldTreeCell is rendered as a {@link Label} when not
@@ -217,10 +219,16 @@
@Override public void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
CellUtils.updateItem(this, getConverter(), hbox, getTreeItemGraphic(), textField);
}
+ /** {@inheritDoc} */
+ @Override protected Optional<T> getEditorValue() {
+ StringConverter<T> converter = getConverter();
+ return converter == null ? Optional.empty() : Optional.of(converter.fromString(textField.getText()));
+ }
+
/***************************************************************************
* *
* Private Implementation *
< prev index next >