Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | 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 3
TheEndless
Channel Surfer

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
Roku Guru

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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.