Solved Custom Window ListItems pass onclick action.
#1
So i am playing a round with a few ideas and have successfully created a few custom windows with there respective XML.
What i am now attempting to do is create a list of items and set the on-click action. right now i have the list showing, and i have set the path. which i can see by using ListItem.FolderPath
I want to be able to set a on-click action some how... to run another script. so the action will be <onclick>RunScript(script.mytestscript)</onclick>

Is this even possible or will i have to go like skin shortcuts and create my own includes also?
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#2
you can set the action as a property of the listitem:
python:
listitem.setProperty('action', 'RunScript(script.mytestscript)')

and use the onClick method to capture the click presses in your addon:
python:
def onClick(self,controlId):
    if controlId == 100:  # id of the container
        listitem = self.getControl(100).getSelectedItem()  # get the listitem
        action = listitem.getProperty('action')  # get the action of the listitem
        xbmc.executebuiltin(action)  # execute the action

in case you've created a media window (which supports multiple views) the code is slightly different:
python:
def onClick(self,controlId):
    if controlId == self.getCurrentContainerId():  # id of the container
        listitem = self.getListItem(self.getCurrentListPosition())  # get the listitem
        action = listitem.getProperty('action')  # get the action of the listitem
        xbmc.executebuiltin(action)  # execute the action
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
Thanks that's what I was looking for... Seems so simple when you spell it out for me. I appreciate your help.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#4
in the script i am getting control of container 9000 to add the items to.
in the xml file i have this control set as default control.
when the window loads i get the following error
Any Idea why i may be getting this error
22:16:52.916 T:7972 ERROR: Control 9000 in window 13000 has been asked to focus, but it can't

and as the error states the focus is not set until i press a couple keys.
Any idea to what maybe causing this?

So quick answer is kodi tries to set focus before container is filled.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#5
(2018-08-22, 05:25)smitchell6879 Wrote: So quick answer is kodi tries to set focus before container is filled.
 correct.

remove the <defaultcontrol> definition from your xml file and see these examples how to do it from python:
https://kodi.wiki/view/HOW-TO:Script_addon
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply

Logout Mark Read Team Forum Stats Members Help
Custom Window ListItems pass onclick action.0