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: 
jaxim
Visitor

callFunc() not working with Group

I am trying to call a function within a component that extends Group. I placed the function within the component's XML interface:
<function name="highlightItem" />


Within the function that is defined in the component's brs file, I place a line that should output to my debugging window; however, that line never gets outputted to the debug window.

sub highlightItem(index)
  ?"highlightItem() has been called"
end sub


This is how I am trying to call the function:
m.menuGroup.callFunc("highlightItem", 1)


So it appears that the function is never called. However, I do the same thing with a few screens which are also components that extend group and and the function in those cases is called properly.  The one difference is that the screens are dynamically added to the scene by calling the following code:

   screen = createObject("roSGNode","Screen1")
   m.screensGroup.appendChild(screen)



What could be the issue here? Why can't I successfully call callFunc() with the group component?
0 Kudos
2 REPLIES 2
jaxim
Visitor

Re: callFunc() not working with Group

nevermind. The problem was due to me targeting the incorrect variable. Instead of m.menuGroup the code should have been targeting a different variable within the code. callFunc() works as intended.
0 Kudos
tim_beynart
Channel Surfer

Re: callFunc() not working with Group

Thanks for posting this! I always thought callFunc() required an associate array as the second parameter.
In the docs it says,"Any context from the caller can be passed to the function via an associative array, which is fully converted/cloned on call."
See here:
https://sdkdocs.roku.com/display/sdkdoc/Handling+Application+Events#HandlingApplicationEvents-FunctionalFields
0 Kudos