sub init()
m.top.observeField("focusedChild", "focusChanged")
end sub
sub focusChanged(evt)
if m.top.isInFocusChain()
child = evt.getData()
while true
if type(child.focusedChild) = "roInvalid" then exit while
child = child.focusedChild
end while
'do some stuff with the focused node
end if
end sub
Accessing the value of the field will result in script errors.
"bmceldowney" wrote:if type(child.focusedChild) = "roInvalid" then exit while
if child.focusedChild = invalid then exit while
"bmceldowney" wrote:
I'm wondering if there is a reliable way to get a reference to the currently focused node.
"bmceldowney" wrote:
So far my biggest hurdle is the fact that simply accessing the focusedChild property results in a "Execution timeout (runtime error &h23)".
"belltown" wrote:
When exiting the dialog, I wanted to get back to where I was before the dialog was invoked. It's not sufficient to just turn off the dialog's visibility; you have to re-set the focus to the previous component. It would be easy if the modal component could just access the "lastFocusedNode", then re-set the focus as it exits.
"bmceldowney" wrote:
From the console, 7.6.
According to the Roku docs, accessing the value of focusedChild will result in "script errors", so I'm assuming that's the problem. That's why I'm looking for any alternative methods to get the currently focused node.
"EnTerr" wrote:"belltown" wrote:
When exiting the dialog, I wanted to get back to where I was before the dialog was invoked. It's not sufficient to just turn off the dialog's visibility; you have to re-set the focus to the previous component. It would be easy if the modal component could just access the "lastFocusedNode", then re-set the focus as it exits.
I can think of couple of complications to this - which may not apply to your case but in principle - first, it's possible the last focused node does not exist at this point (e.g. somebody removed it in the mean time) - what's to do then? And second, somebody was saying there are cases in which setFocus() cannot restore the exact focused item - something to do with compound components (was it grids or row lists... i don't remember).