How to efficiently change multiple buttons using one data trigger

Hi. I’m here migrating from iRule and as I convert I’m trying to improve the look and feel of my controller.

On my “Watch TV” page I have a button for each video source: cable box, gaming console, BD player. Each button has an event trigger on Click sending the right device commands – in particular setting the AVR.InputSource – and all that’s working.

I want the button for the currently-active input source to be visually different – border, or background, or image, etc. – from the others to keep the HR display correct even if someone uses the receiver’s own hardware remote to change the input.

I could add two data triggers to each button: one fired when the AVR.InputSource EQUALS that source which that button selects (e.g., HDMI1) to visually highlight that button, and a second one fired when the source is NOT equal to that button’s source to “unhighlight” the button.

Each button’s triggers would be very similar to the others – the only difference is what value to compare the actual AVR.InputSource data to (HDMI1 for cable box, HDMI2 for BD, etc.). I’m wondering if there’s a cleaner way to accomplish this.

Also, if I decide later that rather than change the background of the button I want instead to change the text color of the active input source button, or the border of the button, I have to go update the two data triggers for each button.

I’ve seen some references (e.g., How to highlight the clicked button?) to using GridView for similar things here in the community but I haven’t fully digested how those examples work. Plus I’m not sure if that approach solves the problem of me changing my mind on how to visually distinguish between active and inactive sources.

Is GridView where I should be looking? Some other approach like Scenes (which I have seen referenced but haven’t fully grokked yet). Scripting?

Thanks.

The GridView is the ideal control for input selection. It will be the simplest to configure. If you use Buttons you will need DataTriggers on each one. Attached is an example you can look it.
GridView_Example.hrp (3.8 KB)

Thanks for the quick response. I now have something inspired by your example and it works pretty well.

Here’s a related follow-up question.

With the GridView bound to the InputSource, I see the selected item change when I click on the HR app or when I change with the AVR’s own remote, just as expected. I’ve also have the GridView’s SelectionChange event turning on the TV and the AVR so the user has a “one-touch” experience.

But I’m concerned that, if the AVR is off to start with, then will HR try to set the AVR’s input source (by virtue of the SelectionChange of the GridView) before the AVR is on and ready to accept the command? I’m assuming here that the AVR won’t see the request to set the input source if it is in standby instead of fully on.

To guard against this (in case it is a problem), I thought about adding an action to the GridView’s SelectionChange event action collection to fetch the now-current setting from the GridView and use that in an AVR.InputSource setter.

I did not see how to retrieve that value. Do I need to record the new value in my own property in a virtual device upon SelectionChange and then fetch from there in the action? Or do something else?

Thanks again.

SelectionChanged only fires after user interaction. It will not fire if the selection is changed by an outside source.

Hmm. That’s not what I’m seeing. If I use the AVR’s remote to change the input I do see the highlighting change in the HR GridView.

The highlighting does change. I thought you were asking about the SelectionChanged event? Those are 2 separate things.

Take a look at the attached project. I show a toast message when SelectionChanged is triggered. If I change the input on my phone, the highlighted value does indeed change, but the toast is not displayed.
GridView_Example_SelectionChanged.hrp (3.9 KB)

Yes, I didn’t ask very clearly and I do get the difference between binding the control to a value and events delivered on the control (which I understand come only from HR user gestures).

Related question… In my GridViewItems I used different values and text. I looked for but did not see a way to fetch the text associated with the GridViewItem indicated by the GridView.SelectedValue. Did I miss it?

Thanks for the help.

No. You can only get the SelectedValue.