seltext problem in TextField

Hello,
I notice that entering some text using .seltext when a textField does not gave the focus, arises some problems:
for instance, in a window I have a textfield, and a pushbutton containing this snippet:
pushbutton1.action event: TextField1.SelText = “1”
Now, clicking the pushbutton several times, if the textfield does NOT have the focus, in the field I get only “11”. Never “111” or “1111” etc.

So I thought to give the focus to the text field, so the pushButton now has this code
TextField1.SetFocus
TextField1.SelText = “1”
But each time I click the button, the textfield erases its content and prints “1”. In other words, the content of the field is always “1”

At present my workarounds are these:

  1. to have it work without giving the focus:
    TextField1.SelStart = TextField1.SelStart
    TextField1.SelText = “1”

  2. To have it work giving focus to the field:
    dim i as Integer = TextField1.SelStart
    TextField1.SetFocus
    TextField1.SelStart = i
    TextField1.SelText = “1”

Could this be considered a bug to be notified through Feedback? Thanks.
Sierra
Xojo 2016 and 2017v2.1, both 32 and 64bit

what version of Xojo?
what platform?

I just duplicated what you described on macOS Sierra with Xojo2016r4.1 and it works just fine

are you sure you don’t have something else that is happening? other events on the textfield perhaps?

my test was a simple window with a textfield and a button
the action of the button was

textfield1.seltext="1"

each press of the button added another character to the textfield

Mac OS 10.12.6
Xojo 2016 and 2017v2.1, both 32 and 64bit

Are you sure the testfield does NOT have the focus?
Try adding a second textfield and manually give it the focus; then push the button several times.

[quote=355508:@Carlo Rubini]Mac OS 10.12.6
Xojo 2016 and 2017v2.1, both 32 and 64bit

Are you sure the testfield does NOT have the focus?
Try adding a second textfield and manually give it the focus; then push the button several times.[/quote]
you are correct… if it doesn’t have focus it reacts like you described…

Dave, thank you for testing and confirmation.

Edited: Sorry. It seems that clicking the link Safari gets confused. Please copy the link and paste it into a browser, it should work.

For others, you may download and test a few scenarios at https://www.dropbox.com/s/au84op8efgct5mt/testfieldSelText.xojo_binary_project?raw=1