Kodi Community Forum

Full Version: script.skinshortcuts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I use single mode for my vertical menu, and use:

Code:
<onunload>RunScript(script.skinshortcuts,type=hidesubmenu&amp;mainmenuID=9000)</onunload>

so that on a return to the homescreen, the previously opened submenu is collapsed. However, focus is not given to the main menu item the previously opened submenu belongs too. Instead, focus is given to the main menu item that is in the position where the submenu item would have been if the submenu would not have been collapsed.

Tried using Control.Move(ID,-1) to work around it, but then this causes an issue with main menu items with no submenu

Hopefully this makes sense..
(2017-05-16, 06:32)Jeroen Wrote: [ -> ]I use single mode for my vertical menu, and use:

Code:
<onunload>RunScript(script.skinshortcuts,type=hidesubmenu&amp;mainmenuID=9000)</onunload>

so that on a return to the homescreen, the previously opened submenu is collapsed. However, focus is not given to the main menu item the previously opened submenu belongs too. Instead, focus is given to the main menu item that is in the position where the submenu item would have been if the submenu would not have been collapsed.

Tried using Control.Move(ID,-1) to work around it, but then this causes an issue with main menu items with no submenu

Hopefully this makes sense..

Just spitballing ideas here, but maybe you could use a groupoverride to add an additional onclick that sets a window property based upon menu position. Then you could use a number of onload conditions that setfocus to the appropriate position based upon the value of the property.

e.g.

Code:
overrides.xml
<groupoverride group="mainmenu" condition="true">SetProperty(FocusPos,$INFO[Container(ID).Position],home)</groupoverride>

Home.xml
<onload condition="Integer.IsEqual(Window(Home).Property(FocusPos),0)">SetFocus(ID,0)</onload>
<onload condition="Integer.IsEqual(Window(Home).Property(FocusPos),1)">SetFocus(ID,1)</onload>
<onload condition="Integer.IsEqual(Window(Home).Property(FocusPos),2)">SetFocus(ID,2)</onload>
etc.

Not sure if this will work (and it's definitely hacky).
(2017-05-16, 10:21)jurialmunkey Wrote: [ -> ]
(2017-05-16, 06:32)Jeroen Wrote: [ -> ]I use single mode for my vertical menu, and use:

Code:
<onunload>RunScript(script.skinshortcuts,type=hidesubmenu&amp;mainmenuID=9000)</onunload>

so that on a return to the homescreen, the previously opened submenu is collapsed. However, focus is not given to the main menu item the previously opened submenu belongs too. Instead, focus is given to the main menu item that is in the position where the submenu item would have been if the submenu would not have been collapsed.

Tried using Control.Move(ID,-1) to work around it, but then this causes an issue with main menu items with no submenu

Hopefully this makes sense..

Just spitballing ideas here, but maybe you could use a groupoverride to add an additional onclick that sets a window property based upon menu position. Then you could use a number of onload conditions that setfocus to the appropriate position based upon the value of the property.

e.g.

Code:
overrides.xml
<groupoverride group="mainmenu" condition="true">SetProperty(FocusPos,$INFO[Container(ID).Position],home)</groupoverride>

Home.xml
<onload condition="Integer.IsEqual(Window(Home).Property(FocusPos),0)">SetFocus(ID,0)</onload>
<onload condition="Integer.IsEqual(Window(Home).Property(FocusPos),1)">SetFocus(ID,1)</onload>
<onload condition="Integer.IsEqual(Window(Home).Property(FocusPos),2)">SetFocus(ID,2)</onload>
etc.

Not sure if this will work (and it's definitely hacky).

I'll experiment with this, thanks JM. As I am using single mode though every item (main or sub) is part of the same container, so the amount of items to create conditions for will be very high.
Yup, what you're trying to do is unlikely to work on the unload, as the script needs to count the number of items visible in order to set the focus correctly - which it's going to find difficult whilst the window is closing.

In addition to jurial's suggestion, two other possibilities:

  1. Add the RunScript in a global override - its possible this will let it run before the window is actually closing
  2. Change the <onunload /> to an <onload />, so the menu gets reset when it next opens
(2017-05-16, 10:30)Jeroen Wrote: [ -> ]I'll experiment with this, thanks JM. As I am using single mode though every item (main or sub) is part of the same container, so the amount of items to create conditions for will be very high.

Yeah I thought about that. But there will only be a limited number of actual positions that are visible in the list. SetFocus only cares about visible relative positions, not absolute positions. So if your menu only has say 10 items visible on screen at any one time, then you really only need 10 conditions (one for each position) -- and the group override I would assume only applies to mainmenu items even in the stacked list, so only one needed to add the onclick which sets the position property.
@Bob: makes sense, will try these out tonight, Cheers Smile

@jurialmunkey: ah, you're right. Would indeed be around 10 items, which is fine Smile
So, I tried all of the methods and functionally, they all work. They all suffer from the same too though, which is the collapsing being clearly visible upon re-entering the home screen. Which of course isn't surprising, but unfortunate Smile

Using jurial's method seems to be a fraction quicker though, using a short transition animation might make it less noticeable.
Oh, and a suggestion / request: would it be possible to allow multiple / "constructed" strings for widget labels?

For instance I would want to do something like this:

Code:
<widget label="YouTube: $ADDON[plugin.video.youtube 30513]"></widget>

But this will simply print out "YouTube: $ADDON[plugin.video.youtube 30513]"

Nothing super important, but one of those nice to have things
(2017-05-16, 21:48)Jeroen Wrote: [ -> ]Oh, and a suggestion / request: would it be possible to allow multiple / "constructed" strings for widget labels?

For instance I would want to do something like this:

Code:
<widget label="YouTube: $ADDON[plugin.video.youtube 30513]"></widget>

But this will simply print out "YouTube: $ADDON[plugin.video.youtube 30513]"

Nothing super important, but one of those nice to have things

I'm sure this is something that's been requested before, and there was no easy way to do it. But remind me on in a month or so, and I'll take a pass at it.
Thanks to your help, I've made it !

I've used templates for widgets, displaying all of them stacked in a grouplist.

Working nice and fast!

Thanks

Tgx
Hi,

I have a question. I try to use template, it's working but I have problem with animations.

Before I used DefaultWidget to show widgets in my overrides.xml :

Code:
<!-- Default Widgets -->
    <widgetdefault labelID="disc">DiscWidget</widgetdefault>
    <widgetdefault labelID="movies">MoviesWidget</widgetdefault>
    <widgetdefault labelID="tvshows">TVShowsWidget</widgetdefault>
    <widgetdefault labelID="music">MusicWidget</widgetdefault>
    <widgetdefault labelID="musicvideos">MusicVideosWidget</widgetdefault>
    <widgetdefault labelID="livetv">LiveTVWidget</widgetdefault>
    <widgetdefault labelID="radio">RadioWidget</widgetdefault>
    <widgetdefault labelID="games">GamesWidget</widgetdefault>
    <widgetdefault labelID="addons">AddonsWidget</widgetdefault>
    <widgetdefault labelID="pictures">PicturesWidget</widgetdefault>
    <widgetdefault labelID="video">VideoWidget</widgetdefault>
    <widgetdefault labelID="favorites">FavoritesWidget</widgetdefault>
    <widgetdefault labelID="weather">WeatherWidget</widgetdefault>

And used this to show my animations :

Code:
<include content="Visible_Right_Delayed_Home">
    <param name="id" value="MoviesWidget"/>
</include>

Code:
<include name="Visible_Right_Delayed_Home">
    <include condition="Skin.HasSetting(no_slide_animations)">Visible_Fade</include>
    <include content="Vis_FadeSlide_Right_Delayed_Home" condition="!Skin.HasSetting(no_slide_animations)">
    <param name="id" value="$PARAM[id]" />
</include>
<include name="Vis_FadeSlide_Right_Delayed_Home">
    <animation type="Conditional" condition="String.IsEqual(Container(9000).ListItem.Property(widget),$PARAM[id])">
        <effect type="fade" start="0" end="100" time="300" tween="sine" delay="300" easing="out" />
        <effect type="slide" start="320" end="0" time="400" delay="300" tween="cubic" easing="out" />
    </animation>
    <animation type="Hidden">
        <effect type="fade" start="100" end="0" time="300" tween="sine" easing="out" />
        <effect type="slide" start="0" end="320" time="300" tween="cubic" easing="out" />
    </animation>
</include>

I used 'String.IsEqual(Container(9000).ListItem.Property(widget),$PARAM[id])' before, but now, what I need to use ?
@Guilouz - If you're using <skinshortcuts>visibility</skinshortcuts> in the template to automatically generate the visibility conditions, then you don't need to use anything - just a type="Visible" animation.
(2017-05-19, 23:40)BobCratchett Wrote: [ -> ]@Guilouz - If you're using <skinshortcuts>visibility</skinshortcuts> in the template to automatically generate the visibility conditions, then you don't need to use anything - just a type="Visible" animation.

I have try this and it's not working :

Code:
<include name="Vis_FadeSlide_Right_Delayed_Home">
        <animation type="Visible">
            <effect type="fade" start="0" end="100" time="300" tween="sine" delay="300" easing="out" />
            <effect type="slide" start="320" end="0" time="400" delay="300" tween="cubic" easing="out" />
        </animation>
        <animation type="Hidden">
            <effect type="fade" start="100" end="0" time="300" tween="sine" easing="out" />
            <effect type="slide" start="0" end="320" time="300" tween="cubic" easing="out" />
        </animation>
    </include>

I use template only for personalized widgets. If user choose personalized widget (with SendClick(312)), he have access to define widgets or he can choose preconfigured widgets and all widgets are already configured and can't be change.

Animations doesn't work in some conditions :

This configuration is OK ->

Main menu
- Movie -> Personalized widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),PersonalWidget)</visible>
- TV Show -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),TVShowWidget)</visible>
- Music -> Personalized widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),PersonalWidget)</visible>
- Music video -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),MusicVideoWidget)</visible>


This configuration is OK ->

Main menu
- Movie -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),MoviesWidget)</visible>
- TV Show -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),TVShowWidget)</visible>
- Music -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),MusicWidget)</visible>
- Music video -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),MusicVideoWidget)</visible>


This configuration doesn't work, animations do not work when personalized widgets are configured on 2 consecutive menu items ->

Main menu
- Movie -> Personalized widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),PersonalWidget)</visible>
- TV Show -> Personalized widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),PersonalWidget)</visible>
- Music -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),MusicWidget)</visible>
- Music video -> Preconfigured widget <visible>String.IsEqual(Container(9000).ListItem.Property(widget),MusicVideoWidget)</visible>
Another question,

Is it possible to add radiobutton for each widget to allow users to choose force widget refresh or not ?
(2017-05-21, 04:17)Guilouz Wrote: [ -> ]Another question,

Is it possible to add radiobutton for each widget to allow users to choose force widget refresh or not ?

Take a look at Custom Shortcut Properties - specifically 'Allow a user to toggle a property'.