Kodi Community Forum

Full Version: Need help with list position
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I suppose i'm going to have to break down and ask for help with my problem cause I can't for the life of me figure out how to do something that seems like it should be simple.. I appreciate in advance any help anyone can give me.

I have 2 lists... list 1 is a dynamic list (discography) of an artist. The other list is a dynamic list that the contents change depending on what I click in list 1.
I have fake buttons for each list so that I can control the onclicks of the list contents.
I click on an album in list 1 and list 2 fills with youtube videos related to the album clicked.
I have list 1 with a width and height 250 x 250 so only 1 item is visible, other items won't show until I scroll.
I have list 2 with a width and height large enough to show 3 videos at a time and I scroll that list to view other items in the list.
If I scroll list 2 to item position 6 and click on it and view the video, then go back to list 1 and click on a different album, the contents of list 2 change to videos of the different album that I clicked in list 1 but the position of list 2 is still at item 6....okay... now to the problem that I can't figure out....

After I click on a different item in list one the contents of list 2 change but the position of the list stays at the previous position (6).
I can't figure out how after I click on an item in list 1 to make list 2 set to item position 1 after the contents change.
In order to see the first item in list 2 after I click on list 1 I have to scroll it back. What I want is after I click on an item in list 1 and the contents of list 2 change, I want the position to also change to item 1 in list 2 so that in list 2 the first 3 videos of the list are visible (item 1,2, and 3) not item 6, 7 and 8.
I seems like "Container.Refresh" is what I need but I don't know where to put it. The wiki isn't clear on how to use the function.
it just reads "Container.Refresh" with a description of (Refresh current listing). I tried to add in my fake button control for list 1 an <onclick>Container.Refresh(ID of List 2)</onclick>
but that don't work. I tried Control.SetFocus(ID of list 2,1) but that don't work.

Is Container.Refresh even what I need? and if so what control do I put it in and how to activate the function for the list ID that I need it to act upon? How do I get list 2 to focus back to item position1 after I click on list 1 and the contents of list 2 change? Any help would be much appreciated. thanks.
not sure if it is possible by pure xml work. You could try to add something like this to your fake buttons:

Code:
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
...
(8 times if max numitems of list 2 is 8)
(this assumes that listitem.label is not empty for all your listitems)
As far as i can remember Control.SetFocus(id,position) does not work for your use case since position 0 means "the first visible listitem", and not "first listitem in list".

If that does not work then post your XMLs. Easier to help out then.
(2014-10-29, 23:27)phil65 Wrote: [ -> ]not sure if it is possible by pure xml work. You could try to add something like this to your fake buttons:

Code:
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
...
(8 times if max numitems of list 2 is 8)
(this assumes that listitem.label is not empty for all your listitems)
As far as i can remember Control.SetFocus(id,position) does not work for your use case since position 0 means "the first visible listitem", and not "first listitem in list".

If that does not work then post your XMLs. Easier to help out then.

"(8 times if max numitems of list 2 is 8)"... Can I set the maximum number of list items in a content tag that's using a plugin path from your extendedinfo script?
(2014-10-30, 00:09)woodside Wrote: [ -> ]
(2014-10-29, 23:27)phil65 Wrote: [ -> ]not sure if it is possible by pure xml work. You could try to add something like this to your fake buttons:

Code:
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
...
(8 times if max numitems of list 2 is 8)
(this assumes that listitem.label is not empty for all your listitems)
As far as i can remember Control.SetFocus(id,position) does not work for your use case since position 0 means "the first visible listitem", and not "first listitem in list".

If that does not work then post your XMLs. Easier to help out then.

"(8 times if max numitems of list 2 is 8)"... Can I set the maximum number of list items in a content tag that's using a plugin path from your extendedinfo script?
Nope, not yet. Does it work at all?
(2014-10-30, 00:32)phil65 Wrote: [ -> ]
(2014-10-30, 00:09)woodside Wrote: [ -> ]
(2014-10-29, 23:27)phil65 Wrote: [ -> ]not sure if it is possible by pure xml work. You could try to add something like this to your fake buttons:

Code:
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
...
(8 times if max numitems of list 2 is 8)
(this assumes that listitem.label is not empty for all your listitems)
As far as i can remember Control.SetFocus(id,position) does not work for your use case since position 0 means "the first visible listitem", and not "first listitem in list".

If that does not work then post your XMLs. Easier to help out then.

"(8 times if max numitems of list 2 is 8)"... Can I set the maximum number of list items in a content tag that's using a plugin path from your extendedinfo script?
Nope, not yet. Does it work at all?

I'm still messing around with it... does it matter what type of list it is? list, wraplist or panel? It seems to be moving it around but it's hard to tell exactly where the position is at in the list after I click but I do know it's not always the first item so I was experimenting a bit. The number of items change depending on how many results there are and your comment "(8 times if max numitems of list 2 is 8)" tells me I have to know the maximum number of results I can get. How can I tell what the maximum number would be? would it be 20 maxResults you have in this line from youtube.py that I would go by and add 20 x the code below?
PHP Code:
base_url 'https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&maxResults=20&type=video' 


PHP Code:
<onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick>
<
onclick condition="!IsEmpty(Container(2).ListItemNoWrap(-1).Label)">Control.Move(2,-1)</onclick
...
panel does not work with lot of stuff, just try a basic list container.

yes, should be 20 then.
Try playing around with PageUp controls.

ie

Code:
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>

adding this to list 2 will scroll it up when you move to list 1 again.

PS I recently tried this myself and you can literally have thousands of PageUp commands and Kodi wont break a sweat.
(2014-10-30, 01:03)Hitcher Wrote: [ -> ]Try playing around with PageUp controls.

ie

Code:
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>

adding this to list 2 will scroll it up when you move to list 1 again.

PS I recently tried this myself and you can literally have thousands of PageUp commands and Kodi wont break a sweat.
good idea Smile

<onclick>SetFocus(2)</onclick>
<onclick>PageUp</onclick>
<onclick>PageUp</onclick>
....
<onclick>SetFocus(ID_OF_PREVIOUS_LIST)</onclick>

would be an alternative for some use cases.
(2014-10-30, 01:03)Hitcher Wrote: [ -> ]Try playing around with PageUp controls.

ie

Code:
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>
<onleft>PageUp</onleft>

adding this to list 2 will scroll it up when you move to list 1 again.

PS I recently tried this myself and you can literally have thousands of PageUp commands and Kodi wont break a sweat.
@Phil, Nah... It doesn't seem to work. I added it 20 times and there were the max 20 videos, It moves it but it does it inconsistently and not always to the first item.Confused

Not sure if this is the best way to accomplish navigating and controlling dynamic lists where you have no control of the onclicks so i'll ask you guys.
What I am using is 2 button controls with a transparent texture to control the onclicks of the lists, the buttons width and the buttons height coincide with the width, height and position of a lists that are filled with content from a plugin path. I made the transparent buttons the same size as the lists so I can either navigate with arrow keys or hover of the lists with a mouse and the transparent button controls are on top of the lists so it catches focus and I can navigate the lists this way, onleft and onright are controlled in the transparent button controls for each list. So whenever i want to do someting with the lists I navigate to the transparent button controls. Is there a better way that a newbie like me hasn't yet found.?
I'm using. ...
PHP Code:
<onleft>Control.Move(50,-1)</onleft>
<
onright>Control.Move(50,1)</onright

in the fake transparrent button controls to navigate my list so I don't believe I can use PageUp for my situation.

Gosh, I wish there was a way to be able to control what the onclicks of dynamic lists do.

[EDIT]
I missed this below in the post above before I wrote this. I'll try this....

<onclick>SetFocus(2)</onclick>
<onclick>PageUp</onclick>
<onclick>PageUp</onclick>
....
<onclick>SetFocus(ID_OF_PREVIOUS_LIST)</onclick>



[EDIT2]
This works.... Thanks guys. I really appreciate your expertise!!!

<onclick>SetFocus(2)</onclick>
<onclick>PageUp</onclick>
<onclick>PageUp</onclick>
....
<onclick>SetFocus(ID_OF_PREVIOUS_LIST)</onclick>