Sub B4XPage_Background
Log("B4XPage_Background-MP")
End Sub
The only time the B4XPage_Background event fires is when I close the app. I added it to one Erel's examples just to make sure I didn't mess something up.
I also tried
B4X:
Private Sub B4XPage_Background
Log("B4XPage_Background-MP")
End Sub
I tested this with MainPage and others with the same result.
The goal is to know when the current page loses focus. I don't really care how.
You can add a focus changed event with JavaObject:
B4X:
Dim jfrm As JavaObject = B4XPages.GetNativeParent(Me)
Dim FocusEvent As Object = jfrm.CreateEvent("javafx.beans.value.ChangeListener", "Focus", Null)
jfrm.GetFieldJO("stage").RunMethodJO("focusedProperty", Null).RunMethod("addListener", Array(FocusEvent))
Private Sub Focus_Event (MethodName As String, Args() As Object) As Object
If MethodName = "changed" Then
Dim focus As Boolean = Args(2)
Log(B4XPages.GetPageId(Me) & " focus: " & focus)
End If...
You can add a focus changed event with JavaObject:
B4X:
Dim jfrm As JavaObject = B4XPages.GetNativeParent(Me)
Dim FocusEvent As Object = jfrm.CreateEvent("javafx.beans.value.ChangeListener", "Focus", Null)
jfrm.GetFieldJO("stage").RunMethodJO("focusedProperty", Null).RunMethod("addListener", Array(FocusEvent))
Private Sub Focus_Event (MethodName As String, Args() As Object) As Object
If MethodName = "changed" Then
Dim focus As Boolean = Args(2)
Log(B4XPages.GetPageId(Me) & " focus: " & focus)
End If
Return Null
End Sub