< prev index next >
modules/javafx.controls/src/main/java/javafx/scene/control/cell/TextFieldListCell.java
Print this page
rev 10463 : 8089514: [TableView, TreeView, ListView, TreeTableView] Clicking outside of the edited cell, node, or entry should commit the value
@@ -33,10 +33,12 @@
import javafx.scene.control.TextField;
import javafx.util.Callback;
import javafx.util.StringConverter;
import javafx.util.converter.DefaultStringConverter;
+import java.util.Optional;
+
/**
* A class containing a {@link ListCell} implementation that draws a
* {@link TextField} node inside the cell.
*
* <p>By default, the TextFieldListCell is rendered as a {@link Label} when not
@@ -169,10 +171,11 @@
public final StringConverter<T> getConverter() {
return converterProperty().get();
}
+
/***************************************************************************
* *
* Public API *
* *
**************************************************************************/
@@ -202,6 +205,12 @@
/** {@inheritDoc} */
@Override public void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
CellUtils.updateItem(this, getConverter(), null, null, textField);
}
+
+ /** {@inheritDoc} */
+ @Override protected Optional<T> getEditorValue() {
+ StringConverter<T> converter = getConverter();
+ return converter == null ? Optional.empty() : Optional.of(converter.fromString(textField.getText()));
+ }
}
< prev index next >