diff --git a/qml/2048.js b/qml/2048.js index 744ae07..a8d7988 100644 --- a/qml/2048.js +++ b/qml/2048.js @@ -82,6 +82,7 @@ function moveKey(event) { cellValues[i] = v2; } } + event.accepted = true; break; case Qt.Key_Right: for (i = 0; i < gridSize; i++) { @@ -102,6 +103,7 @@ function moveKey(event) { cellValues[i] = v2; } } + event.accepted = true; break; case Qt.Key_Up: for (i = 0; i < gridSize; i++) { @@ -118,6 +120,7 @@ function moveKey(event) { } } } + event.accepted = true; break; case Qt.Key_Down: for (i = 0; i < gridSize; i++) { @@ -139,6 +142,7 @@ function moveKey(event) { moveMergeTilesUpDown(i, v, v2, indices, false); } } + event.accepted = true; break; } diff --git a/qml/main.qml b/qml/main.qml index 899ef34..8b44b6b 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -43,6 +43,7 @@ ApplicationWindow { Item { id: helper + focus: false property var myColors: {"bglight": "#FAF8EF", "bggray": Qt.rgba(238/255, 228/255, 218/255, 0.35), "bgdark": "#BBADA0", @@ -62,6 +63,11 @@ ApplicationWindow { focus: true Keys.onPressed: MyScript.moveKey(event) + MouseArea { + anchors.fill: parent + onClicked: parent.forceActiveFocus() + } + Text { id: gameName font.family: "Sans-serif"