[solved] detect button click in window xml - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: [solved] detect button click in window xml (/showthread.php?tid=203461) |
[solved] detect button click in window xml - vitorcarvalhoml - 2014-09-01 Hi! I created a window called custom_quiz.xml that have the following button: Code: <control type="button" id="3000"> In my python file, how can I detect if the button was clicked? Code: def onClick(self, controlID): I didn't find one method to verify this. RE: detect button click in window xml - toyota12303 - 2014-09-02 Hello vitorcarvalhoml, I'm not 100% sure about this but you may be able to do this by toggling a setting on button click and detecting it in Python. On the window you could use PHP Code: <onload condition="Skin.HasSertting(clicked3000)">Skin.ToggleSetting(clicked3000)</onload> On the button you could use PHP Code: <onclick condition="!Skin.HasSetting(clicked3000)">Skin.ToggleSetting(clicked3000)</onclick> And then in the python script you might be able to use something like this to detect if the button was clicked: PHP Code: while xbmc.getCondVisibility('Skin.HasSetting(clicked3000)') == 1: RE: detect button click in window xml - vitorcarvalhoml - 2014-09-02 Hi toyota12303! I end up with this solution: Code: def onClick(self, controlID): The skin code remains the same. Why use onload e onunload tags in window? Where the toggle setting is usually used? Thanks! RE: detect button click in window xml - toyota12303 - 2014-09-03 Hi vitorcarvalhoml! Ahh alright then, I'm not too good with python so that's the best that I could come up with lol I put those onload/onunload tags there because if they weren't then the setting would always be on, meaning the script would think that the button is constantly being pressed. (The onload/onunload would turn it back off.) RE: detect button click in window xml - vitorcarvalhoml - 2014-09-04 I understood now! I guess I have to use your technique in another window. Thanks once again! |