binding action to <onright> or <onleft> [SOLVED]
#1
Hi again,

I have a question about binding an action to a button.
Can actions such as ActivateWindow() be attached to <onright> or <onleft>?

To illustrate my question, I have a main menu:

Movies >
Music
Pictures
Settings

Focusing on the Movies, reveals a submenu include. However I want it so that when you are focused on movies, the right key should reveal the submenu.

The code for the submenu include is:
Code:
<!-- The submenu that offers some additional functions for doing stuff with movies -->
    <include name="HomeMenu_MovieSubMenu">
        <control type="group">
            <orientation>horizontal</orientation>
            <posx>690</posx>
            <posy>155</posy>
            <width>700</width>
            <height>60</height>
            <itemgap>20</itemgap>
            <onleft>1</onleft>
            <onright>1</onright>


            <control type="label">
                <visible>Container(300).HasFocus(1)</visible>
                <label>ADD MOVIE SOURCE</label>
                <width>440</width>
                <height>60</height>
                <textcolor>white</textcolor>
                <font>Medium</font>
                <posx>0</posx>
                <posy>0</posy>

            </control>
        </control>
    </include>

The code for the list item:
Code:
<item id="1">
                 <description>Movies</description>
                 <label>31006</label>
                 <icon>icons/popcorn.png</icon>
                 <onclick>ActivateWindow(Video,movietitles)</onclick>

             </item>

How do I "bind" an action to reveal the include when you tap the right key when you are focused on "Movies?"

I am a beginner, so I have a lot of questions that I couldn't find answers for by searching...

Thanks very much in advance.
Reply
#2
Code:
<onright>SetFocus(ID_OF_CONTAINER_OR_BUTTON)</onright>

http://wiki.xbmc.org/?title=List_of_Built_In_Functions
Reply
#3
Thanks Hitcher!
I'll try that out and report back.
Reply
#4
Hi Hitcher,

I tried to use the <onright> in the item like so:

Code:
<item id="1">
         <description>Movies</description>
         <label>31006</label>
         <icon>icons/popcorn.png</icon>
         <onclick>ActivateWindow(Video,movietitles)</onclick>
         <onright>SetFocus(936,9361)</onright>
</item>

where 936 is the ID of the movie "sub menu" include:

Code:
<!-- The submenu that offers some additional functions for doing stuff with movies -->
    <include name="HomeMenu_MovieSubMenu">
        <control type="group" id="936">
            <orientation>horizontal</orientation>
            <posx>690</posx>
            <posy>155</posy>
            <width>700</width>
            <height>60</height>
            <itemgap>20</itemgap>
            <onleft>1</onleft>
            <onright>1</onright>
            <visible>Container(300).HasFocus(1)</visible>

            <control type="label" id="9361">

                <label>ADD MOVIE SOURCE</label>
                <width>440</width>
                <height>60</height>
                <textcolor>white</textcolor>
                <font>Medium</font>
                <posx>0</posx>
                <posy>0</posy>

            </control>
        </control>
    </include>

I have hidden the submenu by default. I am trying to have it reveal when you <onright> the movie ListItem.
Is it possible?

Thanks in advance!
Reply
#5
Put the <onright> control in the list like this -

PHP Code:
<onright condition="Container(300).HasFocus(1)">SetFocus(936)</onright

and the group visibility needs allowhiddenfocus="true" added.
Reply
#6
Thanks Hitcher,


When you say add it to the list control, you mean like this right?

Code:
    <control type="wraplist" id="300">
            <description>Home Wraplist</description>
            <posx>0</posx>
            <posy>72</posy>
            <width>880</width>
            <height>190</height>
            <onup>2</onup>
            <ondown>3</ondown>
            <viewtype>list</viewtype>
            <onleft>1</onleft>
            <onright condition="Container(300).HasFocus(1)">SetFocus(936)</onright>
            <focusposition>4</focusposition>
            <scrolltime>200</scrolltime>
            <autoscroll>false</autoscroll>
...

and then the group include for the movie submenu:
Code:
<include name="HomeMenu_MovieSubMenu">
        <control type="group" id="936">
            <orientation>horizontal</orientation>
            <posx>690</posx>
            <posy>155</posy>
            <width>700</width>
            <height>60</height>
            <itemgap>20</itemgap>
            <onleft>1</onleft>
            <onright>1</onright>
            <onup>1</onup>
            <ondown>2</ondown>
            <visible allowhiddenfocus="true">false</visible>

            <control type="label" id="9361">
                <label>ADD MOVIE SOURCE</label>
                <width>440</width>
                <height>60</height>
                <textcolor>white</textcolor>
                <font>Medium</font>
                <posx>90</posx>
                <posy>10</posy>
            </control>

        </control>
    </include>

I set the group visibility to false, because I want it to be invisible by default.
Only triggered when you tap right while the "Movie" ListItem is in focus.
Reply
#7
That's correct but I suspect you'll need a button or list to focus on when pressing right.
Reply
#8
I tried changing the group to a list, but no dice.
When you say button, does it mean I create a button and have <onright> set focus on the button, which in turn triggers the submenu?
Reply
#9
If you already have a submenu setup then set focus to that instead.
Reply
#10
OK. I actually implemented a button control and,

1. Set the <onright> on the wraplist to focus on it by:
PHP Code:
<onright>935</onright

where 935 is the ID of the button.

2. Switched to a wraplist (with ID 936) for the submenu. (the decision is design related) Set the <visible> on the submenu wraplist to:
PHP Code:
<visible allowhiddenfocus="true">Control.HasFocus(935)</visible


Now I am able to tap right on the Movie Listitem and focus the button, but the wraplist won't show. What gives?

Full code for the Main menu Wraplist:
PHP Code:
<control type="wraplist" id="300">
            <
description>Home Wraplist</description>
            <
posx>0</posx>
            <
posy>72</posy>
            <
width>880</width>
            <
height>190</height>
            <
onup>2</onup>
            <
ondown>3</ondown>
            <
viewtype>list</viewtype>
            <
onleft>1</onleft>
            <
onright>935</onright>
            <
focusposition>4</focusposition>
            <
scrolltime>200</scrolltime>
            <
autoscroll>false</autoscroll>

            <
itemlayout width="650" height="190">
                <
control type="image">
                    <
texture>$INFO[ListItem.Icon]</texture>
                    <
width>180</width>
                    <
height>180</height>
                    <
posx>90</posx>
                    <
posy>0</posy>
                </
control>

                <
control type="label">
                    <
posx>260</posx>
                    <
posy>50</posy>
                    <
height>90</height>
                    <
info>ListItem.Label</info>
                    <
font>XLarge</font>
                    <
textcolor>white</textcolor>
                    <
align>left</align>
                </
control>
            </
itemlayout>

            <
focusedlayout width="650" height="190">
                <
control type="image">
                    <
texture>$INFO[ListItem.Icon]</texture>
                    <
height>180</height>
                    <
width>180</width>
                    <
posx>90</posx>
                    <
posy>0</posy>
                </
control>

                <
control type="label">
                    <
posx>260</posx>
                    <
posy>50</posy>
                    <
height>90</height>
                    <
info>ListItem.Label</info>
                    <
font>XLarge</font>
                    <
selectedcolor>red</selectedcolor>
                    <
align>left</align>

                </
control>

            </
focusedlayout>

         <
content>
             <
item id="1">
                 <
description>Movies</description>
                 <
label>31006</label>
                 <
icon>icons/popcorn.png</icon>
                 <
onclick>ActivateWindow(Video,movietitles)</onclick>

             </
item>

             <
item id="2">
                 <
description>Music</description>
                 <
label>31004</label>
                 <
icon>icons/earphones.png</icon>
                 <
onclick>ActivateWindow(Music)</onclick>
             </
item>

             <
item id="3">
                 <
description>Photos</description>
                 <
label>31005</label>
                 <
icon>icons/pictures.png</icon>
                 <
onclick>ActivateWindow(Pictures)</onclick>
             </
item>

             <
item id="4">
                 <
description>Settings</description>
                 <
label>[UPPERCASE]SETTINGS[/UPPERCASE]</label>
                 <
icon>icons/settings.png</icon>
                 <
onclick>ActivateWindow(Settings)</onclick>
             </
item>

        </
content>
        </
control>   <!-- end wraplist --> 

Full code for the button control:
PHP Code:
<!-- Button control hack -->
        <
control type="button" id="935">
            <
label>-</label>
            <
posx>670</posx>
            <
posy>90</posy>
            <
width>0</width>
            <
height>0</height>
            <
font>Small</font>
            <
textcolor>white</textcolor>
            <
onleft>300</onleft>
            <
visible>Container(300).HasFocus(1)</visible>

        </
control

Full code for the submenu:
PHP Code:
<include name="HomeMenu_MovieSubMenu">
        <
control type="wraplist" id="936">
            <
posx>690</posx>
            <
posy>155</posy>
            <
width>700</width>
            <
height>60</height>
            <
focusposition>2</focusposition>
            <
onleft>935</onleft>
            <
onright>1</onright>
            <
onup>1</onup>
            <
ondown>2</ondown>
            <
visible allowhiddenfocus="true">Control.HasFocus(935)</visible>

            <
itemlayout width="700" height="60">
            <
control type="label">
                <
info>ListItem.Label</info>
                <
width>440</width>
                <
height>60</height>
                <
textcolor>white</textcolor>
                <
font>Medium</font>
                <
posx>90</posx>
                <
posy>10</posy>
            </
control>

            </
itemlayout>
            <
focusedlayout width="700" height="60">
            <
control type="label">
                <
info>ListItem.Label</info>
                <
width>440</width>
                <
height>60</height>
                <
textcolor>white</textcolor>
                <
font>Medium</font>
                <
posx>90</posx>
                <
posy>10</posy>
            </
control>

            </
focusedlayout>

            <
content>
                <
item id="1">
                    <
label>ADD MOVIE SOURCE</label>
                    <
font>Small</font>
                    <
textcolor>white</textcolor>
                </
item>

                <
item id="2">
                    <
label>BROWSE MOVIES</label>
                    <
font>Small</font>
                    <
textcolor>white</textcolor>
                </
item>
            </
content>


        </
control>
    </include> 

Can you tell me what I am doing wrong?
Reply
#11
Use

PHP Code:
<onright condition="Container(300).HasFocus(1)">SetFocus(936)</onright

to focus on the sub menu, remove the button altogether, and use this

PHP Code:
<visible allowhiddenfocus="true">Control.HasFocus(936)</visible

for the submenu.
Reply
#12
Thanks Hitcher!

Took me a while, but it worked.
I understood the logic behind your suggestions.

However I found out the hard way that for the wraplist to even show up, the <item> ABSOLUTELY needs an <onclick></onclick> tag.
WHYHuh
Reply
#13
Hey Hitcher, are you sure you can have actual functions in the <onright>/<onleft>/<onup>/<ondown> tags? I always thought those tags only worked with control ID's and functions only worked with <onclick> and <onfocus>.
Image
Reply
#14
Hi Mesoptier,

I was able to get it to work per Hitcher's suggestions.
The action is bound to <onright> tag within the wraplist container.

There is just no explicit documentation on the same.
Reply
#15
Cool cool cool, this might make my code a bit easier to understand Big Grin
Image
Reply

Logout Mark Read Team Forum Stats Members Help
binding action to <onright> or <onleft> [SOLVED]0