Private tf As B4XView ' defined in Class_Globals
'tf initialized in DesignerCreateView by means of a locally dimmed EditText or TextFiled var
'Changes view's focus and eventually calls corresponding event in calling module (if set).
'If current text doesn't pass the matching-pattern test, focus is forced to stay unless LetFocusOut permits it anyway
Private Sub tf1_FocusChanged(HasFocus As Boolean)
Dim okmsg As Boolean = True
If Not(HasFocus) Then
If Not(LetFocusOut) Then
If Not(Regex.IsMatch(mpattern, tf.Text)) Then
tf.RequestFocus
okmsg = False
End If
End If
Else
tf.RequestFocus 'this is the "second" call to RF, needed to have the selectall effect
End If
If okmsg And SubExists(mCallBack, mEventName&"_FocusChanged") Then CallSub2(mCallBack, mEventName&"_FocusChanged", HasFocus)
End Sub
Public Sub setFocus
tf1_FocusChanged(True)
End Sub