Solved SetFocus Based on Property of List Item
#1
Is there a way to use a property in a list item to set the focus based on that value? I am setting two property values for each item "upId" and "downId" that I want to use to setFocus <onUp> and <onDown>.

I stripped down what I have to illustrate what I'm trying to do, but it doesn't work.

Is this not the right syntax for ListItem.Property?

Or can you not use a variable for SetFocus()? 

xml:

            <control type="fixedlist" id="90001">
                <onleft>90001</onleft>
                <onright>90001</onright>
                <onup>SetFocus(9000,ListItem.Property(upId),absolute)</onup>
                <ondown>SetFocus(9000,ListItem.Property(downId),absolute)</ondown>
                <pagecontrol/>
                <focusposition>1</focusposition>
                <movement>1</movement>
                <orientation>Horizontal</orientation>
                <itemlayout height="65" width="150">
                    <control type="label">
                        <label>$INFO[ListItem.Label]</label>
                    </control>
                </itemlayout>
                <focusedlayout height="65" width="150">
                    <control type="label">
                        <label>$INFO[ListItem.Label]</label>
                    </control>
                </focusedlayout>
                <content>
                    <item id="1">
                        <label>Item 1</label>
                        <property name="upId">0</property>
                        <property name="downId">4</property>
                    </item>
                    <item id="2">
                        <label>Item 2</label>
                        <property name="upId">1</property>
                        <property name="downId">5</property>
                    </item>
                </content>
            </control>
Reply
#2
Have you tried:-

Quote:<onup>SetFocus(9000,$INFO[ListItem.Property(upId)],absolute)</onup>
Reply
#3
(2021-11-14, 17:34)roidy Wrote: Have you tried:-
Quote:<onup>SetFocus(9000,$INFO[ListItem.Property(upId)],absolute)</onup>
When I try that it goes to the first item in my other fixed list as if the value for $INFO[ListItem.Property(upId)] is being returned as zero.
Reply
#4
Ok, try the hidden label method.

Just before the fixedlist control add two hidden label controls:-

xml:
<control type="label" id="90002">
  <left>-1000</left>
  <label>$INFO[Container(90001).ListItem.Property(upId)]</label>
</control>
<control type="label" id="90003">
  <left>-1000</left>
  <label>$INFO[Container(90001).ListItem.Property(downId)]</label>
</control>

Then in your fixedlist try:-

xml:
<onup>SetFocus(9000,$INFO[Control.GetLabel(90002)],absolute)</onup>
<ondown>SetFocus(9000,$INFO[Control.GetLabel(90003)],absolute)</ondown>

Failing that then it might not be possible to drive SetFocus using an infolabel Sad
Reply
#5
(2021-11-14, 21:38)roidy Wrote: Ok, try the hidden label method.

Just before the fixedlist control add two hidden label controls:-

xml:
<control type="label" id="90002">
  <left>-1000</left>
  <label>$INFO[Container(90001).ListItem.Property(upId)]</label>
</control>
<control type="label" id="90003">
  <left>-1000</left>
  <label>$INFO[Container(90001).ListItem.Property(downId)]</label>
</control>

Then in your fixedlist try:-

xml:
<onup>SetFocus(9000,$INFO[Control.GetLabel(90002)],absolute)</onup>
<ondown>SetFocus(9000,$INFO[Control.GetLabel(90003)],absolute)</ondown>

Failing that then it might not be possible to drive SetFocus using an infolabel Sad

Thank you for your help with this. It is greatly appreciated.

So I tried that but that still doesn't work. When I move the labels from -1000 to something viewable, I see that the label is converting the number to the text string from stings.po.
Example: <label>4</label> shows on the screen as "TV Guide"

Is there a way to make sure that it returns the number instead of the text string? Or is there a different place that I can store it and reference it so that it has the numeric value?

EDIT:
If I put in values in the strings.po to convert the numbers in the label to actual upId and downId values it works.
Example
xml:

            <control type="label" id="90002">
                <left>10</left>
                <label>900011</label>
            </control>
            <control type="label" id="90003">
                <left>10</left>
                <top>30</top>
                <label>900012</label>
            </control>

strings.po
Code:

msgctxt "#900011"
msgid "4"
msgstr ""

msgctxt "#900012"
msgid "5"
msgstr ""

But is there a better way to store/pass those values through the labels or some other control?
Reply
#6
Quote:Is there a way to make sure that it returns the number instead of the text string?

Yes, use the $NUMBER[] function when you set your properties, that could of been the issue from the very start:-

xml:
<content>
<item id="1">
<label>Item 1</label>
<property name="upId">$NUMBER[0]</property>
<property name="downId">$NUMBER[4]</property>
</item>
<item id="2">
<label>Item 2</label>
<property name="upId">$NUMBER[1]</property>
<property name="downId">$NUMBER[5]</property>
</item>
</content>
Reply
#7
PERFECT!

It turned out the property value was the one that needed to use $NUMBER[].

When I did that I was able to go back to 
xml:
<onup>SetFocus(9000,$INFO[ListItem.Property(upId)],absolute)</onup>
and no longer needed to use the extra labels to store/pass the value.

Thank you so much for your help!
Reply
#8
Glad you got it working Big Grin
Reply

Logout Mark Read Team Forum Stats Members Help
SetFocus Based on Property of List Item0