Using "any component" if I don't want it to apply to all components of a type

I am deeply confused about "any component" blocks. What if I want some actions to apply to only a subset of components of a given type, how do I work that ? Let's say I click on "any component" -> "any button" and then select an "when any" block. It seems to me that whatever options I put in that block are going to apply to ALL the buttons in my app; so if I want it to apply to only some, I need to restrict it somehow. Do I have that right ?

The way I've dealt with it is to put the desired buttons into a "list", and first check to see if the clicked button is in that list. If it is, then I call a procedure (which procedure needs to know the index of the button in the list). And I'm not using "notAlreadyHandled" because there are no other blocks that might act on clicks of these buttons.

Does this make any sense at all ? Am I laboring under a fundamental misunderstanding about "any component" blocks ?

Screen Shot 2020-12-19 at 7.25.05 PM

Your logic appears to constrain the any Button Click to those in the list.

Have you tested it? Does it work for you ?

Explain this? Do you have other buttons not in your list ? Are you not using click events with them ?

Yeah, it seems to work as best I can tell so far.

I have one other button (so far), kind of a "master" off/on (the 8 in the list being off/on for 8 channels). I definitely don't want it to be handled in the same way (iow, not by that proc_offon routine). And yes, I'm using a click event with it.

Are you saying I need to be using "notAlreadyHandled" because of this other button ? If so, I'm confused as to why. If it's one of the 8 that's clicked, there's nothing else to handle it. If it's the master, this block won't handle it.

Thank you.

A belt and suspenders guy would also throw an if notAlreadyHandled test around the onoff call, but it is not strictly needed since your extra button is not in that list.

It would speed your app up by eliminating the search through the list for the extra button, though, when you add a Click event button for your other button.

Oh, I see - so "not already handled" doesn't mean in the sense of time - that it was handled previously - but rather that there's some other button-related event that doesn't handle the button that triggered the "any component" event ?

So I could eliminate the "is in list ?" test and just put an "notAlreadyHandled" test around the proc-offon call instead ? As you say, it'd be faster, but it'd also be less code.

That depends on whether or not you plan on keeping other lists of buttons for different purposes, in which case you would still need to see which list the button belongs to.