-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.8.2
Currently it’s not possible to get the pressed information of e.g. Return/Enter and Shift + Return/Enter keys when TableView.editDelegate has focus. The TableView::commit is emitted when Return or Enter is pressed and the editing finishes, but then no information of the Shift key can be obtained.
Getting these events in some form would help e.g. to implement functionality, where the cell below the current one is focused after Enter key and the cell above after Shift+Enter.
The following code snippet shows how with the current implementation the onAccepted, onEditingFinished and Keys.onReturnPressed are never triggered. The focus is set to the TextField for better UX.
TableView {
id: tableView
...
editTriggers: TableView.AnyKeyPressed | TableView.DoubleTapped | TableView.SelectedTapped | TableView.EditKeyPressed
delegate: Rectangle {
required property bool selected
required property bool current implicitWidth: 100
implicitHeight: 20 Label {
id: displayLabel
anchors.centerIn: parent
text: model.display
} TableView.editDelegate: TextField {
x: displayLabel.x
y: displayLabel.y
width: displayLabel.width
height: displayLabel.height
text: display required property bool selected Component.onCompleted: {
selectAll();
forceActiveFocus( Qt.MouseFocusReason );
} TableView.onCommit: {
display = text
console.log("Editing finished, no key information", tableView.currentColumn, tableView.currentRow)
} onAccepted:
console.log("Accepted")
} Keys.onReturnPressed: (event) => {
console.log("return", event.key)
event.accepted = false
} onEditingFinished: {
console.log("Editing finished")
}
}
} selectionModel: ItemSelectionModel{}
}