Kodi Community Forum

Full Version: Weird onclick condition behaviour
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have some strange behaviours with some conditional onclicks and I have no idea why some work and others not. For example this radio button is working fine:

PHP Code:
<control type="radiobutton">
    [...]
    <
onclick condition="!stringcompare(Skin.String(HomeWidget.1.Method),Random)">Skin.SetString(HomeWidget.1.Method,Random)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Random)">Skin.SetString(HomeWidget.1.Method,Last)</onclick>
    <
selected>stringcompare(Skin.String(HomeWidget.1.Method),Random)</selected>
</
control

However if I change it to this, it's not working anymore:

PHP Code:
<control type="radiobutton">
    [...]
    <
onclick condition="!stringcompare(Skin.String(HomeWidget.1.Method),True)">Skin.SetString(HomeWidget.1.Method,True)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),True)">Skin.SetString(HomeWidget.1.Method,False)</onclick>
    <
selected>stringcompare(Skin.String(HomeWidget.1.Method),True)</selected>
</
control

It can be solved by using substring instead of stringcompare but that doesn't explain why the first one works and the second doesn't. The next example is not working at all (also not with substring):

PHP Code:
<control type="radiobutton">
    [...]
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Last)">Skin.SetString(HomeWidget.1.Method,Random)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Random)">Skin.SetString(HomeWidget.1.Method,Last)</onclick>
    <
selected>stringcompare(Skin.String(HomeWidget.1.Method),Random)</selected>
</
control

Does anyone have any clue why this isn't working as expected? Am I doing anything wrong?

Thanks.
using 'True' in a stringcompare never worked.
that's al i know :-)
Than that should be fixed imo. Smile
(2013-04-21, 13:17)`Black Wrote: [ -> ]
PHP Code:
<control type="radiobutton">
    [...]
    <
onclick condition="!stringcompare(Skin.String(HomeWidget.1.Method),True)">Skin.SetString(HomeWidget.1.Method,True)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),True)">Skin.SetString(HomeWidget.1.Method,False)</onclick>
    <
selected>stringcompare(Skin.String(HomeWidget.1.Method),True)</selected>
</
control
Problem here is, that "True" or "False" internally is translated into infobool (either SYSTEM_ALWAYS_TRUE or SYSTEM_ALWAYS_FALSE) but it isn't translated back into "true" or "false" string in comparison - will fix that.

(2013-04-21, 13:17)`Black Wrote: [ -> ]
PHP Code:
<control type="radiobutton">
    [...]
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Last)">Skin.SetString(HomeWidget.1.Method,Random)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Random)">Skin.SetString(HomeWidget.1.Method,Last)</onclick>
    <
selected>stringcompare(Skin.String(HomeWidget.1.Method),Random)</selected>
</
control
I guess that "HomeWidget.1.Method" isn't never assigned with any value so none of onclick conditions will be true here. We would need way to define first/default value for skin string to do it this way.
I have set it to "Last" so it should work (default/first value for a string would indeed be nice)... but I guess it's the same problem as with the fake spin controls. Changing it to

PHP Code:
<control type="radiobutton">
    [...]
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Last)">Skin.SetString(HomeWidget.1.Method,Random)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Random)">Skin.SetString(HomeWidget.1.Method,Last)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Last)">Skin.SetString(HomeWidget.1.Method,Random)</onclick>
    <
selected>stringcompare(Skin.String(HomeWidget.1.Method),Random)</selected>
</
control

fixes it. So you always have to have the same condition in the first and last position, otherwise it either works just one time or not at all. Thanks for the clarification with true/false.
(2013-04-21, 19:09)`Black Wrote: [ -> ]I have set it to "Last" so it should work (default/first value for a string would indeed be nice)... but I guess it's the same problem as with the fake spin controls. Changing it to

PHP Code:
<control type="radiobutton">
    [...]
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Last)">Skin.SetString(HomeWidget.1.Method,Random)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Random)">Skin.SetString(HomeWidget.1.Method,Last)</onclick>
    <
onclick condition="stringcompare(Skin.String(HomeWidget.1.Method),Last)">Skin.SetString(HomeWidget.1.Method,Random)</onclick>
    <
selected>stringcompare(Skin.String(HomeWidget.1.Method),Random)</selected>
</
control

fixes it. So you always have to have the same condition in the first and last position, otherwise it either works just one time or not at all.
Ok, this is something else than I thought: if HomeWidget.1.Method is set to Last then first <onclick> will be executed -> skin string is set to "Random" now. After first onclick was executed we check next onclick condition which will be true now too and so we set skin string back to "last". To solve this we should propably evaluate conditions first and after that execute onclick actions in one go.
PR2810 takes care of the <onclick> stuff.
(2013-06-02, 09:15)jmarshall Wrote: [ -> ]PR2810 takes care of the <onclick> stuff.
Merged. In new builds this issue should be solved.
Any chance to get StringCompare and true problem corrected?
It's quite deep pit for inexperienced skinners Smile