< prev index next >
modules/javafx.controls/src/main/java/javafx/scene/control/TableView.java
Print this page
rev 10463 : 8089514: [TableView, TreeView, ListView, TreeTableView] Clicking outside of the edited cell, node, or entry should commit the value
@@ -558,10 +558,19 @@
getProperties().remove(SET_CONTENT_WIDTH);
}
}
});
+ sceneProperty().addListener((o, oldScene, newScene) -> {
+ if (oldScene != null) {
+ oldScene.focusOwnerProperty().removeListener(weakFocusOwnerListener);
+ }
+ if (newScene != null) {
+ newScene.focusOwnerProperty().addListener(weakFocusOwnerListener);
+ }
+ });
+
isInited = true;
}
@@ -801,10 +810,15 @@
final boolean isCellSelection = ((BooleanProperty)o).get();
pseudoClassStateChanged(PSEUDO_CLASS_CELL_SELECTION, isCellSelection);
pseudoClassStateChanged(PSEUDO_CLASS_ROW_SELECTION, !isCellSelection);
};
+ private InvalidationListener focusOwnerListener = o -> {
+ if (!ControlUtils.isFocusOnNodeOrAnyChild(this)) {
+ edit(-1, null);
+ }
+ };
private final WeakInvalidationListener weakColumnVisibleObserver =
new WeakInvalidationListener(columnVisibleObserver);
private final WeakInvalidationListener weakColumnSortableObserver =
@@ -820,10 +834,13 @@
new WeakListChangeListener<TableColumn<S,?>>(columnsObserver);
private final WeakInvalidationListener weakCellSelectionModelInvalidationListener =
new WeakInvalidationListener(cellSelectionModelInvalidationListener);
+ private WeakInvalidationListener weakFocusOwnerListener =
+ new WeakInvalidationListener(focusOwnerListener);
+
/***************************************************************************
* *
* Properties *
< prev index next >