Add property to AnswerButton.qml to block clicks during external events.
ClosedPublic

Authored by amankumargupta on Mar 19 2018, 1:55 PM.

Details

Summary

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.

Diff Detail

Repository
R2 GCompris
Lint
Lint Skipped
Unit
Unit Tests Skipped
amankumargupta created this revision.Mar 19 2018, 1:55 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptMar 19 2018, 1:55 PM
Restricted Application added a subscriber: KDE Edu. · View Herald Transcript
amankumargupta requested review of this revision.Mar 19 2018, 1:55 PM
amankumargupta edited the summary of this revision. (Show Details)
jjazeix added inline comments.
src/core/AnswerButton.qml
42

why don't you directly put blockClicks: correctAnswerAnimation.running || wrongAnswerAnimation.running
and remove the assignment in correctAnswerAnimation?

amankumargupta added inline comments.Mar 20 2018, 9:23 AM
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.
Maybe there can be similar needs for activities in the future.

Example: in the activity --> blockClicks: isCorrectAnswerAnimationRunning || isWrongAnswerAnimationRunning || someOtherConditionsInTheActivity

amankumargupta added inline comments.Apr 1 2018, 8:22 PM
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?

Yep sure. I'll update the diff with all the changes.

amankumargupta marked 3 inline comments as done.Apr 4 2018, 7:33 PM
amankumargupta retitled this revision from Add readonly properties to AnswerButton.qml to check whether correct and wrong answer animations are running. to Add property to AnswerButton.qml to block clicks during external events..
amankumargupta edited the summary of this revision. (Show Details)
timotheegiet requested changes to this revision.Apr 13 2018, 10:59 AM
timotheegiet added a subscriber: timotheegiet.

Looks like it doesn't really work, I can still click on all buttons during the correct/wrong answer animation.

This revision now requires changes to proceed.Apr 13 2018, 10:59 AM
amankumargupta added a comment.EditedApr 13 2018, 11:04 AM

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

Also I'm not fan of the name blockClicksDuringExternalEvents , maybe something shorter and simpler.. like blockButtonsClicks

blockAllButtonClicks would be good?

amankumargupta edited the summary of this revision. (Show Details)
timotheegiet accepted this revision.Apr 13 2018, 11:56 AM

Looks good now, please commit

This revision is now accepted and ready to land.Apr 13 2018, 11:56 AM