Check if TextField got focus

Can I check if a TextField got the focus? I know there is a Event GotFocus. Tried SelStart, but this is 0 even if the Cursor is in another TextField.

Maybe with something like this:

Sub MouseEnter() If (Me = Me.TrueWindow.Focus) Then ' RectControl has focus End If End Sub

See Window.Focus or ContainerControl.Focus

More precisely: I want to know if a TextField got the focus when I click on a button. Without the GotFocus event and a property if possible (awfully complicated solution).

I wonder why you do not want to use the gotfocus eventhandler … but anyway: In the buttons Action event you can cycle through the controls and evaluate vs. Window.Focus:

Sub Action() For i As Integer = 0 To Self.ControlCount - 1 If Self.Control(i) IsA RectControl Then If Self.Focus=Control(i) Then MsgBox Control(i).Name End If End If Next End Sub

Solution from Oliver works! Thanks!

I do it like:

If textfield1 = textfield1.TrueWindow.Focus Then
MsgBox “got focus”
Else
MsgBox “no focus”
End If