Your Digital Media Has Never Looked So Good

 
jaxim
Topic Author
Posts: 26
Joined: Mon Sep 26, 2016 6:25 am

callFunc() not working with Group

Wed Nov 29, 2017 12:39 pm

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?
 
jaxim
Topic Author
Posts: 26
Joined: Mon Sep 26, 2016 6:25 am

Re: callFunc() not working with Group

Wed Nov 29, 2017 2:37 pm

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.
 
tim_beynart
Posts: 181
Joined: Wed Jul 15, 2015 8:30 am

Re: callFunc() not working with Group

Thu Nov 30, 2017 11:28 am

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

Who is online

Users browsing this forum: norcaljohnny and 2 guests