TextArea - Tab - LostFocus problem/bug?

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?

Of course I don’t need to go back and type the comma to test again, duh!, I added GotFocus to TextArea1:

TextField1.Text = "" TextField2.Text = "" me.Text = "martinez, alejandro" + EndOfLine + "alejandro@example.com"

Now it is easier to see the issue. Just tab - tab - tab and compare with clicking TextArea and TextField.

Sorry, I missed something important:

  • both TextField - UseFocusRing - Off

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.

Well I found out a way to make it work. I just have to wait for the blinking cursor to disappear.

Do you think that on a mac there is information about the cursor and that someway interfere with Xojo’s LostFocus?

Maybe I’m not clear, I’ll try to grab some screen shots.

When I can’t see the cursor, if I press TAB, LostFocus is executed and TextArea1 is updated:

When I can see the cursor, if I press TAB, LostFocus is executed but TextArea1 is not updated:

In short:

  • mac
  • UseFocusRing OFF for TextField
  • use TAB to LostFocus on TextArea
  • only if you press TAB when I can see the blinking cursor in the TextArea (if I can’t see the cursor then it works ok)
  • it always work using the mouse to click on TextField or just by changing UseFocusRing ON for TextField

feedback://showreport?report_id=53085

Someone willing to try the code in feedback://showreport?report_id=53085 to see if they can reproduce this issue?

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.

Works without any problem for me. Tried 2017r1.1 and 21018r3a16 on 10.13.6.

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.