Integer.IsLess comparison of two container infolabels
#1
Hi, is it possible to compare integers where both are pulled from a container infolabel?

E.g. 

Integer.IsLess(Container(6000).CurrentItem,Container(6000).NumItems)

This doesn't seem to be working but it does work if the number being compared to is static

Integer.IsLess(Container(6000).CurrentItem,6) 

I'm basically trying to identify if a focused item in a grouplist is the last element. Tried using Container(6000).HasNext but that didn't seem to work
Reply
#2
If you are simply after identification of the last item, try this

String.IsEmpty(Container(id).ListItemNoWrap(1).Label)

The wiki provides a pretty good description of ListItemNoWrap -
"Basically returns the same as ListItem(offset) but it won't wrap. That means if the last item of a list is focused, ListItemNoWrap(1) will be empty while ListItem(1) will return the first item of the list. Property has to be replaced with Label, Label2, Icon etc. ( eg: Container(50).ListitemNoWrap(1).Plot )"
Reply
#3
(2019-10-07, 16:23)illfigurethisout Wrote: If you are simply after identification of the last item, try this

String.IsEmpty(Container(id).ListItemNoWrap(1).Label)

The wiki provides a pretty good description of ListItemNoWrap -
"Basically returns the same as ListItem(offset) but it won't wrap. That means if the last item of a list is focused, ListItemNoWrap(1) will be empty while ListItem(1) will return the first item of the list. Property has to be replaced with Label, Label2, Icon etc. ( eg: Container(50).ListitemNoWrap(1).Plot )"

Thanks, I tried that first and it doesn't work for some reasons that I can't figure out...

Here's a label with a visibility condition to show only if the last item in the list is selected. I also tried it with 

<visible>IsEmpty(Container(6000).ListItemNoWrap(1).Label)</visible>

Because I wasn't sure of the syntax

xml:

        <control type="label">
            <label>This is the last item in the list</label>
            <font>menu_focused</font>
            <visible>String.IsEmpty(Container(6000).ListItemNoWrap(1).Label)</visible>
        </control>

And here is my control. Please ignore the actual labels, they're just placeholder at the moment

xml:

<control type="grouplist" id="6000">
            <visible allowhiddenfocus="true">false</visible>
            <onup>Close</onup>
            <ondown>Close</ondown>
            <onleft>noop</onleft>
            <onright>noop</onright>
            <orientation>horizontal</orientation>
            <control type="button" id="6002">
                <onclick>XBMC.Quit()</onclick>
                <visible>System.ShowExitButton</visible>
                <label>1</label>
            </control>
            <control type="button" id="6003">
                <onclick>XBMC.Powerdown()</onclick>
                <visible>System.CanPowerDown</visible>
                <label>2</label>
            </control>
            <control type="button" id="6004">
                <onclick>XBMC.Suspend()</onclick>
                <visible>System.CanSuspend</visible>
                <label>3</label>
            </control>
            <control type="button" id="6005">
                <onclick>XBMC.Hibernate()</onclick>
                <visible>System.CanHibernate</visible>
                <label>4</label>
            </control>
            .
            .
            .
          </control>
Reply
#4
To be honest, it's not clear to me how Kodi could find the label in a grouplist of buttons.  I tried a quick grouplist similar to yours with the sole purpose of displaying the label for each of the list items, and could not get anything.   I could display the index number, but nothing else.

I am using this same approach in a wraplist, and it works.    Maybe changing the list type would help?
Reply
#5
(2019-10-07, 17:56)illfigurethisout Wrote: To be honest, it's not clear to me how Kodi could find the label in a grouplist of buttons.  I tried a quick grouplist similar to yours with the sole purpose of displaying the label for each of the list items, and could not get anything.   I could display the index number, but nothing else.

I am using this same approach in a wraplist, and it works.    Maybe changing the list type would help?

Thanks yes I wasn't able to do this either, will try with a wraplist instead!
Reply
#6
Most Container infolabels relate to lists not grouplists.

If you know the ID of the last item in the grouplist then you can compare with:
Code:
ControlGroup(6000).HasFocus(6005)

However, I assume the issue is that you can't be exactly sure what items will be visible - in that case you would need to use a list of some type instead of a grouplist.
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#7
(2019-10-08, 10:24)jurialmunkey Wrote: Most Container infolabels relate to lists not grouplists.

If you know the ID of the last item in the grouplist then you can compare with:
Code:
ControlGroup(6000).HasFocus(6005)

However, I assume the issue is that you can't be exactly sure what items will be visible - in that case you would need to use a list of some type instead of a grouplist.

Thanks yes, the issue is that there is a group of up to 15 buttons, but which ones show depend on independent conditions, so I wouldn/t be able to know for sure which one will be last, unless as a hack I choose one that will always be visible and place that last. But I will give it a go changing to a type of list instead, thanks!

FYI this is for a custom horizontal menu for shutdownmenu, so that the divider doesn't show after the final listitem:

Image
Reply

Logout Mark Read Team Forum Stats Members Help
Integer.IsLess comparison of two container infolabels0