Question on TextField - Focus Received

A simple question about TextFields:

If you have a “MouseDown” event in a TextField, do the commands within that event take precedence over the “FocusReceived” commands? In other words, does the MouseDown event fire the FocusReceived event?

Hope that makes sense…

Hi Barton,

Chances are you’ll receive both events. There are some caveats; Focus won’t fire on some platforms if you don’t allow for a Focus Ring for that field. And the differences between TextField and DesktopTextField should be researched in the docs just to be certain.

If you have both events, and you click on the textfield, MouseDown fires first, and takes precedence over GotFocus.

However, if you tab from another control into the TextField, MouseDown is never fired.

If you’re unsure which order events happen in, add the event handler, and add the following code.

System.DebugLog("Event Handler Name")

change “Event Handler Name” to whichever event handler it is in.
Run the app and check the console to see which fired first.

And “MouseDown” will fire repeatedly if the mouse is held down, according to the docs.

And this will work until (choose one from them or all)… the OS, Xojo, the hazard will change the Events Order of Appearance.

However, if you tab from another control into the TextField, MouseDown is never fired.
You can change the Tab order / if Tab will stay in the TextField or if it will be used to move to another Control (who is able to accept the Focus)…

Thanks, guys for the input. This was very helpful; and I’ll be careful to assign values before the MouseDown is initiated.