How to determine which textfield has focus

Would appreciate if someone could point me to code sample for how I determine which textfield on a window has the focus.

I’m writing some code (using the available examples) for copying selected text to the clipboard and then pasting it somewhere. I need the code to be “generic”, meaning, it should know which control (textfield) has the focus so it will pick up the selected text from that field and paste it elsewhere, regardless of the actual name of the control.

In other words, the sample shows it referencing a specific textfield but I want it to work for whichever textfield has the focus.

Thanks

Window class has a focus property with the current control.

select case self.Focus.Name
case "NameField"
   ...
case "AddressField"
   ...

oh no.

better

if focus = NameField then
// do something with name field
end if

or

if focus isa TextArea then
// handle any text area
end if

He said he wanted it to be generic, so basing it on the name will be more flexible. Eg.,

case FieldName(5)

When a textfield gets the focus have it do App.CurrTextField = self

Then you can just do App.CurrTextField.foo when you need to.

[quote=104038:@Christian Schmitz]if focus = NameField then
Msgbox “Window Name”
end if[/quote]

I do this and also use this:

select Case self.Focus.Name
Msgbox “Window Name”
And It works flawlessly on Mac.

But It doesn’t work on Windows.

What Am I doing wrong?
Thanks

[quote=259502:@Gerardo García]I do this and also use this:

select Case self.Focus.Name
Msgbox “Window Name”
And It works flawlessly on Mac.

But It doesn’t work on Windows.

What Am I doing wrong?
Thanks[/quote]
I solved it using a String Property “FocusName”

And I assign a Value on “GotFocus” Event of every Control.

And Then Use a Select Case FocusName to analyze what control is selected.