To disable clicking on buttons during some external events, we now have a variable blockAllButtonClicks which we can assign the conditions externally during which we want to block the clicks, in addition to when the correct or wrong answer animations are running which is already set by default.
Details
- Reviewers
timotheegiet - Group Reviewers
GCompris: Improvements - Maniphest Tasks
- T8244: Block clicks on AnswerButton during external events.
Diff Detail
- Repository
- R2 GCompris
- Lint
Lint Skipped - Unit
Unit Tests Skipped
src/core/AnswerButton.qml | ||
---|---|---|
42 | why don't you directly put blockClicks: correctAnswerAnimation.running || wrongAnswerAnimation.running |
src/core/AnswerButton.qml | ||
---|---|---|
42 | Yes, this can be a solution and we can make it default. But there may be some other situations in some activities during which we also would want to block buttons, along with the duration when animation is running, so these variables can come in handy for them when the activity needs to redefine blockClicks externally ? Like, in Solar System activity, we also need to block it when the closeness meter animation is running. Example: in the activity --> blockClicks: isCorrectAnswerAnimationRunning || isWrongAnswerAnimationRunning || someOtherConditionsInTheActivity |
src/core/AnswerButton.qml | ||
---|---|---|
42 | Or, another solution is we can have a variable in AnswerButton.qml, say property bool blockClicksOnActivityEvents: false and we will set--> blockClicks: correctAnswerAnimation.running || wrongAnswerAnimation.running || blockClicksOnExternalEvents And as per needs to block the answer buttons in the activity in more events, this variable can be used to set them. |
the second solution seems better as we don't expose internal values to the exterior. Can you also remove the blockClicks assignements in the file?
Looks like it doesn't really work, I can still click on all buttons during the correct/wrong answer animation.
Yes that's obvious...because the other buttons won't be blocked due to animation running in another button (they're independent).
That's why we need to have the variable blockClicksDuringExternalEvents which we will initialise in the activity to block the clicks on all the buttons during the common events.
Ah right, I was confusing the button animation with the bonus animation, that's why I was surprised.
Note: maybe you can use a enabled: !blockClicks on the MouseArea rather than an if in onPressed
Also I'm not fan of the name blockClicksDuringExternalEvents , maybe something shorter and simpler.. like blockButtonsClicks
Pushed to master.
Commit link: https://cgit.kde.org/gcompris.git/commit/?id=847bb1c171289893a21f6864caf9bc9af7d42f11