getMostRecentFocusOwner() is an AWT method on a Window object, assuming you are not using AWT but are using JavaFX (Default in B4j) then you can use getFocusOwner on the Scene:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
Sleep(0)
Dim FormJO As JavaObject = MainForm
Dim Scene As JavaObject = FormJO.GetField("scene")
Log(Scene.RunMethod("getFocusOwner",Null))
End Sub
Will return null if there is no focused view. You may not need the Sleep(0) depending on where you call it from.
Dim FormJO As JavaObject = MainForm
Dim Scene As JavaObject = FormJO.GetField("scene")
dim selectedNode as node
Try
selectedNode = Scene.RunMethod("getFocusOwner",Null)
Log(selectedNode.Tag) ' all node methods available
Catch
Log("no node has focus")
End Try
Dim SelectedNode As Node = Scene.RunMethod("getFocusOwner",Null)
If SelectedNode Is TextField Then
Dim TF As TextField = SelectedNode
Log(TF.Text)
End If