Forum Discussion

scorpiontahir02's avatar
9 years ago

onChange does not work for default value in interface variables

I have defined <interface> of my <component> node as

<interface>
<field type="bool" id="value" onChange="setCheckedItem" />
</interface>

Which should call, "setCheckedItem" whenever value is assigned. But when I do from another component "mycomp.value = false" it never triggers "setChecktedItem". It might be because false is default value for bool, but I think "setCheckedItem" should be called for each assignment to "value".

I have achieved this with a workaround for now, by calling "setCheckedItem" in the last statement of my "init" sub

3 Replies

  • TheEndless's avatar
    TheEndless
    Channel Surfer
    "scorpiontahir02" wrote:
    but I think "setCheckedItem" should be called for each assignment to "value".

    If you want the event to fire on every set, regardless of whether the value changes or not, then you should add the "alwaysNotify" attribute and set the value to "true".
  • "TheEndless" wrote:
    If you want the event to fire on every set, regardless of whether the value changes or not, then you should add the "alwaysNotify" attribute and set the value to "true".

    Thanks TheEndless, that solved the issue.
  • Hm, seems someone has been thinking "outside the box" at Roku.
    Seems to me a better approach would be if the event handler could see both the old and the new value (e.g. as part of roSGNodeEvent) and then act accordingly.