Hello,
I need to know the value of selStart when i click into a textArea: at present, if I do not click twice, the position of the insertion point following the mouseDown, does not match selStart.
For instance, with the following snippet inside the mouseDown event handler of a textArea:
label1.text = str(me.selStart)
Clicking at the 10th character of the text, label1 may show 300 or any other wrong number; clicking again at the same position, I get the right selStart-value.
Xojo 2016v1.1
OSX 10.11.6
I do not know if this problem affects also win32.
Any suggestion how to fix the problem?
Thank you.
Function MouseDown(X As Integer, Y As Integer) As Boolean
Label1.text = str(me.SelStart)
End Function
Type: “I go to London”
Clicking between “o” and “n” of London, label1 shows 14
Click again at the same position, label1 shows 10
Click anywhere else, label1 shows 10; click again at it shows the real value of selStart.
And so on and so forth: that is, the first click shows the last value of selSart. Only at the second click I get the value of the insertion point.
In my app I have several textAreas and when I used the timer approach I had to subclass a timer in order for the timer to understand which textArea was the one with focus.
But if mouseDown has to be ruled out, then I agree that the timer approach may be the best solution. In fact, SelChange too returns the right selStart value, but it creates other problems, for instance, right-clicking in the textArea, the full word will get selected.