Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 

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
0 Kudos
3 Replies
TheEndless
Level 7

Re: onChange does not work for default value in interface variables

"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".
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos

Re: onChange does not work for default value in interface variables

"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.
0 Kudos
EnTerr
Level 8

Re: onChange does not work for default value in interface variables

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.
0 Kudos