Hi Michel, I used the code in the TextField MouseDown event as posted by Tim above:
if self.focus <> me then
me.SelectAll
return true
end
I had the same problem as Ron (the OP) in that I was seemingly unable to select the text field with the mouse at all.
After doing some more research, I came across this similar thread:
https://forum.xojo.com/25958-textfield-selectall-method/0
It looks like it’s a timing issue related to Windows & Xojo. As someone already pointed out, this issue hasn’t been a problem with VB or FileMaker (In my case) so it must be related to Xojo.
Anyway, from that thread above, In the MouseDown event I tried:
me.SetFocus
me.SelectAll
Return True
At least that code works in highlighting/selecting the entire text but then you cannot insert the cursor where needed if required.
Then I saw your code:
[quote]Here is what I did that works here :
Function MouseDown(X As Integer, Y As Integer) As Boolean
if self.focus.Handle <> me.handle then
me.SetFocus
Return True
end if
End Function
Sub MouseUp(X As Integer, Y As Integer)
me.SelectAll
End Sub
In MouseDown, I test if the TextField already has focus. If not, I set focus, return true, and in MouseUp selectall. If not (the TextField already has focus), I let the user click wherever he pleases to put the caret within the text.
[/quote]
Looks very promising but I cannot get it to work.
The first part of the code is a function? - where does this go? I tried putting it in the MouseDown event but got a NilObjectException error. I then created the Function MouseDown but not sure where to go from there.