I have a textfield mask to enter a phone number “##########” (limit text = 0) that gets formatted in the lost focus event.
If (for example), you need to change the last digit of the phone number, when you click on the end of the text field and backspace once, the entire field is erased.
There are no other event handlers for the field (except the lost focus event). Do you think it is the mask that is causing this behavior?
The LOSTFOCUS event only occurs when you leave that control (via TAB, or mouseclick)… a Backspace does not cause the LOSTFOCUS event to fire.
If pressing the BS key deletes all the text, then all the text was already selected (assuming you have no other code in the KEYDOWN or other events)…
Also “assuming” you are only supporting the phone # format of one locale, you can use the MASK for the whole thing (although personally, I avoid the mask property all together, and control things in the KEYDOWN event.
You might try putting this in the GOTFOCUS event
me.SelStart=Len(me.text)
me.SelLength=0
this will put the cursor at the end of the text, and make sure NOTHING is selected prior to the first key press by the user.
I quickly tried to reproduce the issue from David’s description[quote=286073:@David Schlam]There are no other event handlers for the field (except the lost focus event). Do you think it is the mask that is causing this behavior?[/quote]
I tried to quickly create a small project from your description in 2013R3.3 and none of what you tell happens. Could you try to make a small project that demonstrate the issue and post it. Otherwise we are shooting in the dark here.
and how is one supposed to download your sample… it seems what ever site you used only works with Windows…
as it wanted to download a ZipExtractor EXE (which of course a) I couldn’t use and b) wouldn’t trust anyways)…
So I won’t be able to provide you any more insight I’m afraid.
I was under the impression that mask did the job of format and mask, most likely because that’s the way it was done in 4D (which is what I used for years prior). So I see that format, when you select the textfield, is removed and then reformats the text after you lose focus.
I wish I spotted that sooner. It would have saved me a lot of coding.