Skip to content

Commit

Permalink
fix: the numeric keypad cannot input
Browse files Browse the repository at this point in the history
使用 Keys.forwardTo 代替判断 event.text

Issues: linuxdeepin/developer-center#8495
  • Loading branch information
zsien authored and kegechen committed Jun 13, 2024
1 parent b637558 commit a6d4ab2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
11 changes: 3 additions & 8 deletions qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ Control {
}
}
onTextChanged: {
searchEdit.focus = true
SearchFilterProxyModel.setFilterRegularExpression(text.trim())
// reset highlighted item
if (searchResultGridViewContainer.visible) {
Expand All @@ -562,15 +563,9 @@ Control {
cs: searchResultGridViewContainer.cellHeight
}

Keys.forwardTo: [searchEdit]
Keys.onPressed: {
if (searchEdit.focus === false && ((event.modifiers === Qt.NoModifier || event.modifiers === Qt.ShiftModifier || event.modifiers === Qt.KeypadModifier) && event.text && !"\t\r\0 ".includes(event.text))) {
searchEdit.focus = true
if (searchEdit.text) {
searchEdit.text += event.text
} else {
searchEdit.text = event.text
}
} else if (baseLayer.focus === true) {
if (baseLayer.focus === true) {
// the SearchEdit will catch the key event first, and events that it won't accept will then got here
switch (event.key) {
case Qt.Key_Up:
Expand Down
1 change: 1 addition & 0 deletions qml/windowed/BottomBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Control {

onTextChanged: {
console.log(text)
searchEdit.focus = true
SearchFilterProxyModel.setFilterRegularExpression(text.trim())
SearchFilterProxyModel.invalidate()
}
Expand Down
6 changes: 2 additions & 4 deletions qml/windowed/WindowedFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,9 @@ Item {
}
}

Keys.forwardTo: [bottomBar.searchEdit]
Keys.onPressed: function (event) {
if (bottomBar.searchEdit.focus === false && !bottomBar.searchEdit.text && ((event.modifiers === Qt.NoModifier || event.modifiers === Qt.ShiftModifier || event.modifiers === Qt.KeypadModifier) && event.text && !"\t\r\0 ".includes(event.text))) {
bottomBar.searchEdit.focus = true
bottomBar.searchEdit.text = event.text
} else if (bottomBar.searchEdit.focus === true || baseLayer.focus === true) {
if (bottomBar.searchEdit.focus === true || baseLayer.focus === true) {
// the SearchEdit will catch the key event first, and events that it won't accept will then got here
switch (event.key) {
case Qt.Key_Up:
Expand Down

0 comments on commit a6d4ab2

Please sign in to comment.