I was trying to find why my code worked some times and not others.
I found that using Tab in a TextArea to exit and LostFocus, then the TextArea is not refreshed with new information (most of the time*). If I click on the TextFields (or other app) it always refresh with new information.
The simplest project is this:
New Project
1 TextArea
2 TextFields
This code on TextArea’s LostFocus:
Dim t As String
Dim ta(),tb() As String
t = TextArea1.Text
ta = t.Split(EndOfLine)
TextField1.Text = ta(0).Trim.Titlecase
If TextField1.Text.CountFields(",") = 2 Then
tb = TextField1.Text.Split(",")
TextField1.Text = tb(1).Trim + " " + tb(0).Trim
End If
TextField2.Text = ta(1).Trim
TextArea1.Text = " "
TextArea1.Text = TextField1.Text + EndOfLine + TextField2.Text
Me.TextSize = 14
Screen capture:
for this screen recording I completed the process 6 times with Tab and only 1 refreshed ok.
There is no point on showing what happens when I use the mouse to click on the other TextFields, it always refresh the TextArea.
Don’t know how to search Feedback for this particular problem.
Is this enough information for a case?
There are several issues with focus handling on macOS I know of. One is that it’s not even guaranteed that you get a LostFocus before the new control’s GotFocus.
As a work-around try using a Timer with Period=0 in which you handle the LostFocus - that may help whenever you attempt to modify the control that you just got the event for.
It is happening in 2 computers both with macOS 10.12.6
The case was closed as ‘Not Reproducible’, but I can reproduce the behavior at will with my system. Just want to know if this is related to macOS Sierra and maybe fixed in High Sierra/Mojave or in fact I was not clear.
I feel like I can predict the future (if the first line in TextArea will change or not) but people don’t believe me.
I can make the program work as expected every time, or make it fail every time, or 1 and 1, etc.
Thank you very much Tanner. I did some tests and is a 10.12.6 issue.
Installed 10.13.6 and 10.14 beta on Virtualbox and it works without any problem. I was going to test my app on a real 10.13.6 machine from a friend, but thanks to your report I don’t need to do it.
Is good to know is a macOS issue. It would be nice when Xojo close a case as ‘Not Reproducible’ at least say what macOS version was tested on. If they can’t reproduce it with 10.12.6 then they didn’t test it right.
Also, to those that want to make it work on 10.12.6, just add me.Invalidate as the last line in LostFocus, that way ti works with cursor on or off.