How to make an image into a button - button appears but onclick doesnt run
#8
(2020-07-11, 05:51)jurialmunkey Wrote:
(2020-07-10, 00:27)henryjfry Wrote:
(2020-07-09, 23:48)Hitcher Wrote: Ah right, it's getting the info from a plugin. In that case an onclick control to the list itself.

Do you mean add an onclick property to the list item within the add-on?

Like this?

listitem.setProperty('action', 'RunScript(script.mytestscript)')

How would I do that for multiple items in a list?

Or can the onclick be added to the list in the skin?

No, onclick is added to the control itself.

xml:

<control type="list">
<onclick condition="BOOLEANCONDITION">ACTION-OR-BUILTIN</onclick>
<itemlayout>...</itemlayout>
<focusedlayout>...</focusedlayout>
<content>...</content>
</control>

Skinning Manual Reference:
https://kodi.wiki/view/Skinning_Manual#O...ick_action

Boolean Conditions:
https://kodi.wiki/view/List_of_boolean_conditions

Built-in Functions:
https://kodi.wiki/view/List_of_built-in_functions

Action IDs:
https://kodi.wiki/view/Action_IDs

However, if these are just normal video plugin lists and you just want the default onclick behaviour specified by the plugin then you should remove all onclick/buttons from the list and specify a target value in your content tag like so:

xml:
<content target="videos">$var[similarInfo]</content>

Target specifies which media window the content should open in when clicked if the listitem is a folder (i.e. target can be videos, music, pictures, or programs - which correlate to MyVideosNav.xml, MyMusicNav.xml, MyPics.xml, and MyPrograms.xml respectively). Since you're using a video plugin, you want it to open in the video media window.

Skinning Manual Reference:
https://kodi.wiki/view/Skinning_Manual#F...ic_content

More info about activating windows:
https://kodi.wiki/view/Opening_Windows_and_Dialogs
Thanks for that info, I was able to get a working onclick action.  

Code:

                <!--Similar List-->
                <control type="panel" id="352">
                    <posx>600</posx>
                    <posy>250</posy>
                    <width>800</width>
                    <height>714</height>
                    <onleft>ClearProperty(AdditionalInfo)</onleft>
                    <onleft>Dialog.Close(352)</onleft>
                    <onleft>SetFocus(8000)</onleft>

                    <onback>ClearProperty(AdditionalInfo)</onback>
                    <onback>Dialog.Close(352)</onback>
                    <onback>8000</onback>
                    <onback>SetFocus(8000)</onback>
                    
                    <scrolltime>200</scrolltime>
                    <orientation>vertical</orientation>
                    <focusposition>0</focusposition>
            
                    <viewtype label="actor list">list</viewtype>
                    <visible allowhiddenfocus="true">String.IsEqual(Window.Property(AdditionalInfo),similar)</visible>
                    <animation effect="fade" start="100" end="25" time="0" condition="Container(352).IsUpdating">Conditional</animation>
                    <animation effect="slide" start="0,0" end="0,1000" time="0" delay="0" condition="!String.IsEqual(Window.Property(AdditionalInfo),similar)">Conditional</animation>

                <onclick condition="System.HasAddon(script.extendedinfo) + $EXP[IsMovieDBType]">RunScript(script.extendedinfo,info=extendedinfo,dbid=$INFO[ListItem.DBID],name=$INFO[ListItem.Title])</onclick>
                            <onclick condition="System.HasAddon(script.extendedinfo) + $EXP[IsTvShowDBType]">RunScript(script.extendedinfo,info=extendedtvinfo,dbid=$INFO[ListItem.DBID],name=$INFO[ListItem.TvShowTitle])</onclick>
                            <onclick condition="System.HasAddon(script.extendedinfo) + [String.IsEqual(ListItem.DBTYPE,season) | String.IsEqual(ListItem.Property(DBTYPE),season)]">RunScript(script.extendedinfo,info=seasoninfo,tvshow=$INFO[ListItem.TvShowTitle],season=$INFO[ListItem.Season],silent=True)</onclick>
                            <onclick condition="System.HasAddon(script.extendedinfo) + $EXP[IsEpisodeDBTypeNoFallback]">RunScript(script.extendedinfo,info=extendedepisodeinfo,dbid=$INFO[ListItem.DBID],tvshow=$INFO[ListItem.TvShowTitle],season=$INFO[ListItem.Season],episode=$INFO[ListItem.Episode],silent=True)</onclick>

                    <!-- itemlayout movies -->
                    <itemlayout height="357" width="240">
                        <control type="group">
                            <width>233</width>
                            <height>342</height>
                            <include>PosterPanelLayout</include>
                        </control>
                    </itemlayout>
                    <focusedlayout height="357" width="240">
                        <control type="group">
                            <width>233</width>
                            <height>342</height>
                            <include>PosterPanelLayoutFocus</include>

                        </control>

                    </focusedlayout>
                    <content>$VAR[similarInfo]</content>
                </control>

I had tried adding an onclick in different places in this section after having read some stuff in the skinning manual but I hadn't been able to get it working before so im guessing it must be setup before the layout?

But thanks for the help, like i say i've been trying to figure out stuff from the skinning manual but i find it hard to figure out how stuff actually works in practice without specific context. Like in this instance I had seen the overriding onclick reference but all the information I found seemed to be specific to a list and I couldn't figure out how to apply it to the panel i was looking at.  Your comment showing the two layout tags was all the context i needed, versus however long i spent googling or editing xml files, reloading my skin and seeing what happens.


Anyway i'm slowly getting there, although i suspect i have some basic knowledge gaps when it comes to xml and structure. I've basically never done xml before so i dont know whats a kodi thing and whats a general xml thing, which makes interpreting the stuff on the wiki difficult as it will only ever include the most basic examples.
Reply


Messages In This Thread
RE: How to make an image into a button - button appears but onclick doesnt run - by henryjfry - 2020-07-11, 15:39
Logout Mark Read Team Forum Stats Members Help
How to make an image into a button - button appears but onclick doesnt run0