v18 Choose what option the main menu starts in
#1
Hello all,

As part of the process of migrating the Amber skin to Leia, I am trying to implement having the user choose what main menu option the skin starts in.  I am not using script.skinshortcuts for my menu, I have a fixedlist.  I was able to achieve this by storing the id of the main menu option the user selects as a skin string, and using 
xml:
<defaultcontrol always="true"></defaultcontrol>
in the definition of the fixedlist.

The issue is that by using the always = "true", which works with the id of the element of the list, every time the Home window is loaded the fixedlist positions itself on the element with the dfaultcontrol id, not just when Kodi starts or when the skin is reloaded.  If I don't use the always = "true", then I cannot use the id of the element of the list and position it correctly on startup.

I am sorry if I am not explaining myself well.  I am also trying not to rewrite the whole menu system to achieve the functionality, as I am just learning to skin.  

Any feedback and pointers are completely welcome and will be greatly appreciated!

Regards,

Bart
Reply
#2
What if you change:
always=“true “
To:
condition=“Window.Previous(startup)”
?
Reply
#3
(2019-04-10, 01:49)mikeSiLVO Wrote: What if you change:
always=“true “
To:
condition=“Window.Previous(startup)”
?

Thanks Mike! Unfortunately, that didn't work, it seems only the always="true" takes the element id. With your suggestion it started in the default item.

Regards,

Bart
Reply
#4
(2019-04-10, 04:08)bsoriano Wrote:
(2019-04-10, 01:49)mikeSiLVO Wrote: What if you change:
always=“true “
To:
condition=“Window.Previous(startup)”
?

Thanks Mike! Unfortunately, that didn't work, it seems only the always="true" takes the element id. With your suggestion it started in the default item.

Regards,

Bart

Downloaded your GitHub version and I tried replacing the defualtcontrol 300 and adding onloads to the home.xml:
Code:
    <onload condition="!Window.Previous(startup)">300</onload>
    <onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),5)">SetFocus(300,5)</onload>

I only tested movies cause on new install it defaults to add-ons but that seems to work for me.

You would have to test adding:
Code:
    <onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),6)">SetFocus(300,6)</onload>
    <onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),7)">SetFocus(300,7)</onload>
    <onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),8)">SetFocus(300,8)</onload>
Ect...
To see if there are any other issues.

It will not work when doing a skin reload cause startup will never be the previous window after Kodi launches and you would have to delete your DefaultMenuPosition include from the id="300" fixedlist so it doesn't force the defaultcontrol when backing back out to the Main Menu.
Reply
#5
(2019-04-10, 04:53)mikeSiLVO Wrote:
(2019-04-10, 04:08)bsoriano Wrote:
(2019-04-10, 01:49)mikeSiLVO Wrote: What if you change:
always=“true “
To:
condition=“Window.Previous(startup)”
?

Thanks Mike! Unfortunately, that didn't work, it seems only the always="true" takes the element id. With your suggestion it started in the default item.

Regards,

Bart 

Downloaded your GitHub version and I tried replacing the defualtcontrol 300 and adding onloads to the home.xml:
Code:
<onload condition="!Window.Previous(startup)">300</onload>
<onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),5)">SetFocus(300,5)</onload>

I only tested movies cause on new install it defaults to add-ons but that seems to work for me.

You would have to test adding:
Code:
<onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),6)">SetFocus(300,6)</onload>
<onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),7)">SetFocus(300,7)</onload>
<onload condition="Window.Previous(startup) + String.IsEqual(Skin.String(DefaultMenuPos),8)">SetFocus(300,8)</onload>
Ect...
To see if there are any other issues.

It will not work when doing a skin reload cause startup will never be the previous window after Kodi launches and you would have to delete your DefaultMenuPosition include from the id="300" fixedlist so it doesn't force the defaultcontrol when backing back out to the Main Menu. 
@mikeSiLVO , thank you so much! With this I can certainly position the list on the saved position on startup.  The complication I am facing with this skin is that the user can disable menu options they don't want to see, and there are 15 custom menu options that they can add (or not); so, I don't always know that Movies will be in position 4 of the list.  That is why I was asking about moving the list to a specific element id in the list, because the element ids do not change.

Is there any way I can store what element id is in what position on the list so that I can save the position as a skin string and then use your code to move the list to that position at startup? 
 In the skinsettings.xml, how could I fill a list with the ids and position of the main menu list, so that I know that when the user chooses Movies for example as the startup position, that the position of the list in skinsettings is the same position as the main menu list, so I know that if I save this position, I will start in Movies when Kodi starts? I don't know if I am making enough sense.

Thank you again for your help!

Regards,

Bart
Reply
#6
I didn't think of that...

I tested using:
Code:
<include condition="Window.Previous(startup)">DefaultMenuPosition</include>
and that works except when backing out to the Main Menu the first time and only the first time. I think it is because the include to always focus that specific id is what Kodi remembers and after backing out that include isn't visible anymore so it uses the default position based on <focusposition>2 until you exit home a second time then Kodi remembers the last focused item.

Perhaps you can use an onunload of skinsettings to ask if you would like to set the startup position and open a custom dialog and use an onclick to set ListItem.Property(id) and use that to set the focus number but now I am just spitballing and have no idea if that would work... Huh
Reply
#7
(2019-04-10, 16:16)mikeSiLVO Wrote: I didn't think of that...

I tested using:
Code:
<include condition="Window.Previous(startup)">DefaultMenuPosition</include>
and that works except when backing out to the Main Menu the first time and only the first time. I think it is because the include to always focus that specific id is what Kodi remembers and after backing out that include isn't visible anymore so it uses the default position based on <focusposition>2 until you exit home a second time then Kodi remembers the last focused item.

Perhaps you can use an onunload of skinsettings to ask if you would like to set the startup position and open a custom dialog and use an onclick to set ListItem.Property(id) and use that to set the focus number but now I am just spitballing and have no idea if that would work... Huh  
Thanks @mikeSiLVO , I appreciate you continuing to help me think of ways to achieve this. 


Unfortunately, ListItem.Property(id) does not work, it's not one of the infolabels available.  I will keep looking at other ways to do this.

Regards,

Bart
Reply
#8
While porting my latest skin version from Krypton to Leia i also noticed the buggy behaviour of defaultcontrol in a fixedlist main menu in Leia.

Does anyone have some new inside regarding a fix or latest workarounds? Thanks Smile
⬅️⬅️ Feel free to leave a 👍 on useful posts  |  A Confluence ZEITGEIST (A modern reimagination of Confluence)  |  axbmcuser REPO (Download Link)  |  Kodi 17.7 DSPlayer x64 BETTERGUI (2020 build)
Reply
#9
(2019-11-22, 02:28)axbmcuser Wrote: While porting my latest skin version from Krypton to Leia i also noticed the buggy behaviour of defaultcontrol in a fixedlist main menu in Leia.

Does anyone have some new inside regarding a fix or latest workarounds? Thanks Smile

@axbmcuser, I gave up trying to figure this out and rewrote Amber’s menu and widgets using skinshortcuts. Sorry I don’t have an answer for you.

Regards,

Bart
Reply
#10
Information 
Thanks for your reply. Did anyone report the bug?

In my case the fixedlist-defaultfocus-bug mainly affects the first time load of the Home.xml main menu which in my case (should) focus the first item of the fixedlist main menu.
For now i stick with this workaround:

Startup.xml add code:
xml:

<!-- KODI 18 fixedlist defaultcontrol bug fix workaround -->
<onload>SetProperty(HomeDefaultControlTempFix,,home)</onload>

Home.xml add code:
xml:

<!-- KODI 18 fixedlist defaultcontrol bug fix workaround -->
<onload condition="String.IsEmpty(Window(home).Property(HomeDefaultControlTempFix)) + Window.IsActive(Home)">SetFocus(9000,0)</onload>
<onunload condition="String.IsEmpty(Window(home).Property(HomeDefaultControlTempFix))">SetProperty(HomeDefaultControlTempFix,done,home)</onunload>


Of course this may not be usable in more complex use cases.

EDIT1:

The above variant does not work when selecting a profile from the LoginScreen because of the strange double-loading of Home.xml after selecting a profile on the LoginScreen, so i refined it like this:

Startup.xml add code:
xml:

<!-- KODI 18 defaultcontrol bug fix -->
<onload>SetProperty(HomeDefaultControlTempFix,,home)</onload>
<onload>CancelAlarm(HomeDefaultControlTempFixAlarm,silent)</onload>

Home.xml add code:
xml:

<!-- KODI 18 fixedlist defaultcontrol bug fix workaround -->
<onload condition="String.IsEmpty(Window(home).Property(HomeDefaultControlTempFix)) + Window.IsActive(Home)">SetFocus(9000,0)</onload>
<onunload condition="String.IsEmpty(Window(home).Property(HomeDefaultControlTempFix))">AlarmClock(HomeDefaultControlTempFixAlarm,SetProperty(HomeDefaultControlTempFix,done,home),00:00:01,silent)</onunload>
⬅️⬅️ Feel free to leave a 👍 on useful posts  |  A Confluence ZEITGEIST (A modern reimagination of Confluence)  |  axbmcuser REPO (Download Link)  |  Kodi 17.7 DSPlayer x64 BETTERGUI (2020 build)
Reply

Logout Mark Read Team Forum Stats Members Help
Choose what option the main menu starts in1