I have a form with several Text Fields. All are set to UseFocusRing.
I have the following in each textfield’s GotFocus event: Me.SelectAll
When I tab from field to field any existing text is highlighted whenever the textfield gets focus. However, if I just click on a textfield to give it the focus, any existing text is not highlighted.
I don’t recall having this problem with Real Studio.
Could this be because clicking with the mouse happens after the select-all code and thus deselects the text? It just happens so fast you can’t see it. You might look at the mousedown event within the textArea and see if you can code around that.
inside your TextField.SelChange event handler. When you click within a TextField, a cursor positioning changes the “SelStart” property, in turn, firing the SelChange event.
[quote=52741:@Ron Bower]Marc - Good thought. I put the SelectAll code in the MouseDown Event and still no good.
I’m just looking for a way to select all existing text whenever the user clicks on a text field.
Ron Bower[/quote]
And you might want to set a flag to prevent running the code once the field is active, so that any subsequent single clicks (like changing the insertion point) don’t select the entire text.
Thanks Mark! forgot that part… which is why MouseDown would not work properly, since MouseDown happens when insertion is performed. (even if a flag was set)
Best method to prevent over coding, would be to create a TextField Subclass handling this once, then set all TextFields you need this to occur in, Super’s to the subclassed TextField name…
Remember… in the current version of the Xojo, MouseDown and HTMLViewers SecurityChanged (WebKit) do not fire properly for Windows builds…
To see the MouseDown bug, create a windows application, use the MouseDown event, return true, and do something in the MouseUp event… Hopefully will be fixed in the next release
To use the subclass I made, copy and paste it to your application, in the inspector, change the TextField Super from TextField to SATextField…no coding required on your part to get it to work (although you may want to view the subclass to see how it was achieved…)
I loaded your code and looked at it and think I can undetsnad it.
However, when I run the program the text fields work exactly the same - they will highlight existing text when I tab into them but not when I click in them
I did notice that your application was created using Xojo 3.3 and I am using Xojo 3.2 - I’ll have to wait for the upgrade and then come back to this problem.
I loaded your code and looked at it and think I can undetsnad it.
However, when I run the program the text fields work exactly the same - they will highlight existing text when I tab into them but not when I click in them
I did notice that your application was created using Xojo 3.3 and I am using Xojo 3.2 - I’ll have to wait for the upgrade and then come back to this problem.
[quote=52798:@Ron Bower]I just upgraded to Xojo 3.3 and still getting the same.
Matthew: Using your example the text fields highlight on a Tab into, but not on a Mouse Click into.
Tim: Using your suggestion I can’t select the text field with a mouse click.
Ron Bower[/quote]
I have come up with a working version of SATextField with a little “dynamic array” fix… i have tested it in real studio 2012r2 and Xojo 3.1,3.2,3.3 and the beta 4 (to be released) it works immaculately. Here is the new download link. Please confirm or deny that it works.