Hi I am developing an SDK which shows custom views when user performs some events in the app. I have created xml of those views and had been able to render it via scene. But an issue faced is that when this custom view is shown focus is transferred to the view but when it is dismissed the focus does not come back to node which previously had the focus. Any way to achieve the same?
Asked
Active
Viewed 627 times
2 Answers
2
You can, for example set observer on your custom view to observe if that view is visible again with:
m.customview.ObserveField("visible", "onVisibleChange")
After that you need to write onVisibleChange function like this:
Sub onVisibleChange()
if m.customview.visible
m.customview.setFocus(true)
end if
End Sub
This is one possible solution to this issue.

U.Mitic
- 744
- 1
- 6
- 14
-
My issue is that I need to bring back the focus to the node which had focus prior to showing of the custom view. Is that possible? – Vaisakh Vinod Jan 23 '18 at 04:44
-
You could create custom interface string value named lastFocusNode on your first CustomView. Then moment before you open next customview set this value from interface to the name of the last focused node. After that just add if statement in the onVisibleChange function, to check interface value and act upon it, when first CustomView becomes visible again. I did not test this but it should work. – U.Mitic Jan 23 '18 at 05:03
0
Create a component that handles adding/removing/setting focus on components and make it a part of any other views you have.

JSON Derulo
- 76
- 2