Commit 80d9ddad authored by Timothée Giet's avatar Timothée Giet
Browse files

graph-coloring, fix keyboard focus issue after config change

there was a bug that after using the combobox inside the activity config,
the keyboard focus was lost when coming back in the activity.

Using forceActiveFocus() on the background worked, but then keyboard events were duplicated,
unless using event.accepted = true... but then escape didn't work anymore to close the help
popup or the activity...

So the best solution I found is to handle the input in a dedicated item,
and use forceActiveFocus on it.
parent 30b298fb
...@@ -38,7 +38,6 @@ ActivityBase { ...@@ -38,7 +38,6 @@ ActivityBase {
sourceSize.width: width sourceSize.width: width
sourceSize.height: height sourceSize.height: height
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
focus: true
signal start signal start
signal stop signal stop
...@@ -71,12 +70,20 @@ ActivityBase { ...@@ -71,12 +70,20 @@ ActivityBase {
property bool keyNavigationMode: false property bool keyNavigationMode: false
} }
onStart: { Activity.start(items) } onStart: {
Activity.start(items);
eventHandler.forceActiveFocus();
}
onStop: { Activity.stop() } onStop: { Activity.stop() }
Keys.enabled: !bonus.isPlaying
Keys.onPressed: { Item {
items.keyNavigationMode = true; id: eventHandler
items.currentKeyZone.handleKeys(event); focus: true
Keys.enabled: !bonus.isPlaying
Keys.onPressed: {
items.keyNavigationMode = true;
items.currentKeyZone.handleKeys(event);
}
} }
Column { Column {
...@@ -402,13 +409,17 @@ ActivityBase { ...@@ -402,13 +409,17 @@ ActivityBase {
currentActivity: activity.activityInfo currentActivity: activity.activityInfo
onClose: { onClose: {
home() home();
eventHandler.forceActiveFocus();
} }
onLoadData: { onLoadData: {
if(activityData && activityData["mode"]) { if(activityData && activityData["mode"]) {
items.mode = activityData["mode"]; items.mode = activityData["mode"];
} }
} }
onStartActivity: {
eventHandler.forceActiveFocus();
}
} }
Bar { Bar {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment