Activating/deactivating an image when several buttons are clicked but others are not

Feb 11, 2021

Activating/deactivating an image when several buttons are clicked but others are not.

 

Hello,
I'm currently struggling with an issue with trigger, variables and states.
I have tried many things, none satisfying.

My problem:
I have 8 images which are turned into buttons with 3 states (Normal, Deactivated, Selected), these images are several choices. So I'll refer to them as "the choices" hereafter

On the other side of the screen I have 9 images which have to states Deactivated and Normal. These are "the results". By default they are deactivated.

Let's say that Result1 should turn to "Normal" when any of choices 1, 2, 3 and/or 4 are selected AND NONE of choices 5, 6, 7 nor 8 is.

Also, Result1 should turn back to "Deactivated" (default state) when none of 1,2, 3 ad 4 are selected OR if any of 5, 6, 7 or 8 is.

How can I do this?

So far I succeeded into getting Result1 to Normal when I select the proper ones, and deactivate if I select another one, but if I unselect 5 for example, the state doesn't change. (But if unselect one of 1, 2, 3 or 4, it is deactivated :'( )

My triggers so far are :

Change state of Result1 to Normal if ANY OF objects 1,2, 3 or 4 is selected, on the conditions that 5 is NOT selected
AND 6 is NOT selected
AND 7 is NOT selected
AND 8 is NOT selected

Change state of Result1 to Deactivated if ANY OF objects 5,6,7 or 8 is selected.


Then I tried other things, unsuccessfully. I tried things with variables but I was hoping that something like "Change Result1 to Normal if variable var_1 = True" but I can only say "if variable var_1 changes" :/

 

The overall idea is to get a result depending on the choices, so I need to be able to say :

If choices 1, 2, 3 or 4 and none of the others --> display Result1

If choices 2, 4, 6 and 7 and none of the others --> display Result2

If choices 2, 3,and 8 and none of the others --> display Result3

If choices 5 and 6 and none of the others --> display Result4

etc.


Thanks for your help.

 

 

 

 

7 Replies
Ian Israel Saavedra

Hello Ana, from your example:

"So far I succeeded into getting Result1 to Normal when I select the proper ones, and deactivate if I select another one, but if I unselect 5 for example, the state doesn't change. (But if unselect one of 1, 2, 3 or 4, it is deactivated :'( )"

Does Choice 5 have a trigger to change its state from selected to 'not selected' i.e. Normal or Deactivated? If you haven't already, I suggest adding a trigger to change its state back to Normal or to Deactivated, when it is clicked, only if its state is Selected, so that the 'not selected' trigger from the following is met.

"Change state of Result1 to Normal if ANY OF objects 1,2, 3 or 4 is selected, on the conditions that 5 is NOT selected
AND 6 is NOT selected
AND 7 is NOT selected
AND 8 is NOT selected"

Does that make sense?

Ana Luiz

Thank you for your answer,

I thought that this was automatic, that if I created an object with a Normal and a Selected state, then if the user clicks on it, it becomes selected, and if the user clicks again it is then unselected and therefore back to normal...
So I don't see what kind of trigger that would be, it feels like this would require 2 triggers:
- change state of choice5 to selected when user clicks if choice5 is Normal
- change state of choice5 to Normal when user clicks if choice5 is Selected

I tried that but choice5 is always Normal :D

So I guess I misunderstood ^^

Walt Hamilton

- change state of choice5 to selected when user clicks if choice5 is Normal
- change state of choice5 to Normal when user clicks if choice5 is Selected

The reason this doesn't work is that state changes are made before triggers are executed, and both triggers are executed every time there is a click.

So if the state is normal, the click changes it to Selected, the first trigger condition is not true so it is ignored, and the second trigger changes state to Normal. If the state is Selected, the click changes it to Normal, the first trigger changes it to Selected, and the second trigger changes it to Normal.

Part of your other problem may stem from trying to use three states, rather than using the built-in triggers that come with Selected and Normal state. Another part may stem from not using the learner action of clicking as the When part of your triggers.

Try this sample, which only changes the State of the first four Results.

It works because it changes the state of the Results when the learner clicks a choice. Then it changes the state depending on the state of all the choices.  To keep from having to put every trigger on every choice, I put them on a layer. Clicking a choice invokes the layer which sets the results.

Any questions please ask.

Ana Luiz

Hello !
So I tried. I thought I understood, but I can't make it work although I feel like I've made the same thing, so clearly I'm missing something :/

img_GP should be Normal when either 2, 5, 6 or 7 are selected and none of the others
img_Fil should be Normal when either 1, 3 or 7 are selected and none of the others.

So far I can make them turn to normal, but when I select something else, or unselect something that should be selectedn the state doesn't change :/

(for example, if I click 2 and 5, img_GP is Normal (good), but then if I click 3, it doesn't change. And if I unselect 2 and 5 it still doesn't change)

Thanks for your help.