How to set a rule to indicate "If this specific row in a Repeater is clicked do <something>"

repeater-widget

#1

Simple example. Repeater1 has 1 Column (“Fruits”) with 2 rows: Apples and Oranges. I want to color a second widget depending on what repeater row is clicked. If “Apples” row is clicked, set rectangle to red, “Oranges” row, set rectangle to orange, etc. I have succeeded using the following rule, on the Repeater:

On Click or Tap, If text on this equals “Apples”,
Set Dynamic Panel State to AppleState (red)

I wonder though, if there is an alternative way to do this, for example, with a rule inside the rectangle itself. Something like “If Row 1 in Repeater is clicked, set to red, if Row 2, set to orange, etc.”

Might seem like I am trying to solve a problem which already has a solution, but I have found wanting this sort of feature for more complex examples. Also feels much more efficient. I have heard of this “listener” method but I have not been able to understand if it would be useful in this situation.
changing from repeater.rp (56.2 KB)


#2

changing from repeater.rp (73.8 KB)

image

Two methods.


#3

That’s awesome thank a lot. A quick question:

Why do you need to have a Local Variable set up in your second method?

I deleted this variable and it still seemed to work fine. I tried to find a place where this is used and did not…


#4

It’s not necessary, you can delete it.