ControlList Help?
#1
Hoping someone can spot my problem... I'm trying to resize each buttons width to fit within the background image.
I've tried all the variables nothing seems to change the image size and buttons size.

Any Help would be apprecated, Thanks

Image

Code:
# ControlList (x, y, width, height[, font, textColor, buttonTexture, buttonFocusTexture, selectedColor, imageWidth, imageHeight, itemTextXOffset, itemTextYOffset, itemHeight, space, alignmentY])n"//, shadowColor])
        self.list = xbmcgui.ControlList(198, 160, -50, 600, 'font12', 'FFFFFFFF', 'button-nofocus.png', 'pstvButtonFocus.png', 'FFFFFFFF', 0, 0, 0, 0, 40, 0, 40)
        self.addControl(self.list)
        self.list.addItems(items=Titlelst)
        self.list.setWidth(200)
        self.setFocus(self.list)
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#2
Solved issue with self.list.setWidth(200)
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
New problem i'm hoping to find a solution for Smile

take the same code as OP...

Code:
Titlelst = ['Foo','Bar']

is it possible to set the focus position to one of the elements in the list, ie.

Code:
self.setFocus(self.list[1])

List starts focused on 'Bar', instead of rearranging the order of Titlelst to achieve the same result.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#4
Titlelst is a list of items, right?

Anyway, I think setFocus only works for controls, not items with a list control.

Maybe what you want is:

Code:
self.setFocus(self.list)
self.list.selectItem(1)

Hmm, this page offers another alternative to try: http://kodi.wiki/view/List_of_built-in_functions

Code:
xbmc.executebuiltin('Control.SetFocus(%s,1)' % yourControlID)

But it also makes it look like this might work as well.
Code:
self.setFocus(self.list, 1)
Reply
#5
(2015-01-13, 00:48)Karnagious Wrote: Titlelst is a list of items, right?

Anyway, I think setFocus only works for controls, not items with a list control.

Maybe what you want is:

Code:
self.setFocus(self.list)
self.list.selectItem(1)

Hmm, this page offers another alternative to try: http://kodi.wiki/view/List_of_built-in_functions

Code:
xbmc.executebuiltin('Control.SetFocus(%s,1)' % yourControlID)

But it also makes it look like this might work as well.
Code:
self.setFocus(self.list, 1)

Thanks I'll give it a try Smile

::Update::
Code:
self.list.selectItem(1)
worked great
Code:
self.setFocus(self.list, 1)
Didn't work
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#6
(2015-01-13, 02:18)Lunatixz Wrote:
Code:
self.list.selectItem(1)
worked great

Unfortunately it does not work great, moreover it does not work at all despite what you see. selectItem() method has a major bug that makes it unusable - it changes visual selection of ControlList but does not change the internal index that holds info about which item is currently selected. I've posted a bug report on Track about this, but the ticket was closed without fixing: the developers seem to consider this bug irrelevant.
Reply
#7
(2015-01-13, 18:05)Roman_V_M Wrote:
(2015-01-13, 02:18)Lunatixz Wrote:
Code:
self.list.selectItem(1)
worked great

Unfortunately it does not work great, moreover it does not work at all despite what you see. selectItem() method has a major bug that makes it unusable - it changes visual selection of ControlList but does not change the internal index that holds info about which item is currently selected. I've posted a bug report on Track about this, but the ticket was closed without fixing: the developers seem to consider this bug irrelevant.

Not 100% sure but I think this isnt a bug, but a badly chosen name for a function name which should be called focusItem (?)
tried selecting with xbmcgui.ListItem.select()?

EDIT: the same naming issue also applies to getSelectedItem()
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#8
(2015-01-13, 18:19)phil65 Wrote:
(2015-01-13, 18:05)Roman_V_M Wrote:
(2015-01-13, 02:18)Lunatixz Wrote:
Code:
self.list.selectItem(1)
worked great

Unfortunately it does not work great, moreover it does not work at all despite what you see. selectItem() method has a major bug that makes it unusable - it changes visual selection of ControlList but does not change the internal index that holds info about which item is currently selected. I've posted a bug report on Track about this, but the ticket was closed without fixing: the developers seem to consider this bug irrelevant.

Not 100% sure but I think this isnt a bug, but a badly chosen name for a function name which should be called focusItem (?)
tried selecting with xbmcgui.ListItem.select()?

Darn you are right, I never checked to see that it actually selected the proper item... It does focus the correct item, but no info.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#9
Why not force a meaningless navigation as a way to kick the internal index to change the selected control.

For example, if your focused/highlighted control has no navigable control to its right, then running this line (simulating a direction key press by the user) might make kodi think the item is selected.

Code:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.Right", "id": 1 }')

This would need to be run when the control has focus; so after the window is displayed.

Alternatively, if there is a control on the right, you could simulate a very quick down-up action by the user to return to your control.

Code:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.Down", "id": 1 }')
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.Up", "id": 1 }')

Or I suppose you could just run the Input.Down immediately on creation instead of selectItem(1).
Reply
#10
(2015-01-14, 03:20)Karnagious Wrote: Why not force a meaningless navigation as a way to kick the internal index to change the selected control.

For example, if your focused/highlighted control has no navigable control to its right, then running this line (simulating a direction key press by the user) might make kodi think the item is selected.

Code:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.Right", "id": 1 }')

This would need to be run when the control has focus; so after the window is displayed.

Alternatively, if there is a control on the right, you could simulate a very quick down-up action by the user to return to your control.

Code:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.Down", "id": 1 }')
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.Up", "id": 1 }')

Or I suppose you could just run the Input.Down immediately on creation instead of selectItem(1).
I though about this... but json input commands are slow... and code is ugly.

Id rather split the list, so that the item I want starts in focus. Then append the leftovers.

Hopefully the bug for item selection will be fixed soon.

Thanks
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#11
xbmc.executebuiltin("Down")
xbmc.executebuiltin("Up")
...
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#12
(2015-01-14, 04:28)phil65 Wrote: xbmc.executebuiltin("Down")
xbmc.executebuiltin("Up")
...

Or that.
Reply
#13
(2015-01-13, 18:19)phil65 Wrote: Not 100% sure but I think this isnt a bug, but a badly chosen name for a function name which should be called focusItem (?)

Why on earth we need to focus item without having a way to find out programmatically which item is currently selected? Currently selectItem() method breaks internal consistency of a ListItem object: visual selection moves to another item, but the internal index stays on the previous item. After applying selectItem() what you will see will be different from what your program code tells you, which sounds crazy. Are you sure this was the intended behavior?

Obviously, this method was intended as a direct analogue of QListWidget.setCurrentRow() method or .NET WinForms ListBox.SelectedItem property, but wasn't implemented correctly.

Quote:tried selecting with xbmcgui.ListItem.select()?

This does not work for ListItem instances stored in a ControlList object.
Reply

Logout Mark Read Team Forum Stats Members Help
ControlList Help?0