Getting the current selection
#16
Thought I'd bump this. I noticed the following was committed yesterday and wasn't sure if that was to address this or not.

https://github.com/xbmc/xbmc/commit/283e...4debd82091

jmarshall - does the above address the ability to get the selected item or is that for something else? Would still love some way to get the selected list item via python and then manipulate it (e.g. update it's label, update it's context menu items)
Reply
#17
It's a bit late, but i was looking to do this also,
i've done a mix of info of this page and it work for label and property describe here : http://wiki.xbmc.org/?title=InfoLabels :

for container with id 9000:

print xbmc.getInfoLabel('Container(9000).ListItem(0).Label')
Reply
#18
BUMP
exact same problem.

It seems like such a basic thing!.. to be able to get the currently selected ListItem as an object?? c'mon, that's really basic stuff that should be supported.

From what I understand, the first call gets the correct window, but then the getFocus() method returns the wrong control.
In my case, I'm calling the script from within a list item's context menu, so I'm guessing it's referencing either the listgroup or one of the buttons (I can't seem to find a human-readable data field to identify for sure).

All I need is to be able to return the currently selected ListItem as an object... should be simple enough!
(frustrated)
Reply
#19
bump!

Wow, this thread has been around for more than a year and still not addressed in the code??
I've found many ways to do:
  • Get the DBID of the selected item (int)
  • Get name/path/nameandpath of selected item (string)
  • Get the current window (object)
But still no way to get the item as an object!

Personally, I'm not looking to manipulate the list-item itself (in the GUI, that is). I want to manipulate database information of that list-item.

So in theory, I wouldn't need to get the actual
Code:
activeWindow.activeControl.activeListItem

I would be very happy to just create an item on the fly to be able to access the database:
PHP Code:
import xbmc
DBID 
xbmc.getInfoLabel('ListItem.DBID')
pseudoItem loadItem(DBID# << My problem is right here!
pseudoItem.setProperty(namevalue# << Make DB changes here 

Help, anyone!
Confused
Reply
#20
Is there already a solution for getting the active listitem? I want to add 'CastAndRole' but when I first get this information I dont have access to my listitem anymore...
Reply
#21
dump for interest
Reply
#22
Bumpetybumpbump!
Reply
#23
Bump
Reply
#24
Not sure if these are what you're looking for...

Code:
xbmc.getInfoLabel('System.CurrentControl')
Works for me to get to get the selected item.

Code:
getSelectedItem(...)
getSelectedItem() --Returns the selected item as aListItem object.

*Note, Same as getSelectedPosition() , but instead of an integer aListItem object
is returned. Returns None for empty lists.
See windowexample.py on how to use this.

example:
    - item = cList.getSelectedItem()
To get as an object.
Reply
#25
(2016-09-19, 12:23)woodside Wrote: Not sure if these are what you're looking for...

Code:
xbmc.getInfoLabel('System.CurrentControl')
Works for me to get to get the selected item.

Unfortunately, this will give the currently focused list, but not the ListItem...

Quote:
Code:
getSelectedItem(...)
getSelectedItem() --Returns the selected item as aListItem object.

*Note, Same as getSelectedPosition() , but instead of an integer aListItem object
is returned. Returns None for empty lists.
See windowexample.py on how to use this.

example:
    - item = cList.getSelectedItem()
To get as an object.

And this whole thread is about how this method doesn't work (still Rofl) for controls that were created in XML.

For my usage, that doesn't work. I am filling a list control in an XML dialog with items via a <content> tag, but am unable to retrieve the actual ListItems through any means, as far as I can tell.

I can use JSON-RPC to get various information (basically the same as the standard InfoLabels) for all the files in a directory, or I can access the InfoLabels the way that I am now (Container(id).ListItem(position).xxxxx). Unfortunately, neither of these methods gives the ability to get the original ListItem.

To add to the matter, it appears that most of the API for ControlList (and probably other controls) is broken when dealing with XML windows. I'm unable to use really any of the methods related to items in a ControlList, like size() or getListItem(index), the latter of which really seemed like the ticket here.

Honestly, it's not really surprising that this hasn't ever been fully addressed (or addressed at all, maybe?), but it certainly is disappointing Sad
Reply

Logout Mark Read Team Forum Stats Members Help
Getting the current selection0