When user wants to edit a cell then a text field appears in this cell. How can I hide this textfield (close it) when user click something outside the table?
Asked
Active
Viewed 286 times
0
-
Do you have custom TableCell or used TextFieldTableCell.forTableColumn()? – Uluk Biy Jun 11 '15 at 05:53
-
@Uluk Biy I have used TextFieldTableCell.forTableColumn(). – Jun 11 '15 at 07:03
-
1possible duplicate of [TableView doesn't commit values on focus lost event](http://stackoverflow.com/questions/29576577/tableview-doesnt-commit-values-on-focus-lost-event) – ItachiUchiha Jun 11 '15 at 07:29
1 Answers
0
You need to use custom TableCell
, since the TextFieldTableCell
does not support committing the edit on focus loosing.
See "Example 12-11 Alternative Solution Of Cell Editing" of this Table View Tutorial.
Quoting from tutorial:
Note that the default implementation of the TextField control requires that users press the Enter key to commit the edit. You can redefine the TextField behavior to commit the edit on the focus change, which is an expected user experience. Try the modified code in to implement such an alternative behavior.

Uluk Biy
- 48,655
- 13
- 146
- 153
-
"You can redefine the TextField behavior to commit the edit on the focus change, which is an expected user experience." This is what I am talking about. They understand what most of the users wait and do another way. – Jun 11 '15 at 08:18