Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Did I find a bug with Textboxes?
Message
From
14/08/2001 17:12:50
 
 
To
13/08/2001 15:34:50
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00542582
Message ID:
00543774
Views:
17
Thanks for the snippet, Mike.

I agree 100% that the invisible characters need to be there. There just needs to be consistency between selstart and the actual text of seltext.

I've actually created a workaround for the bug which is a little more complicated than yours, but it seems to do the trick. In both the double-click and the mouse-up methods of the text box, a form property is set which contains the seltext value. Then, when I modify the value of seltext later, it compares that form property to the subst(editbox.value,.selstart+1,.sellength). If it's different, then it calculates the number of invisible characters and programmatically sets .selstart to the proper value. The bug only occurs when a user adds non-invisible characters (i.e. it doesn't seem to happen by just hitting enter), so by comparing the form property which was set to match seltext to the subst value, I can tell whether the calculation needs to be done.

Interestingly, it seems that the value of seltext has to be determined in the control's events, versus later on in the form. If I just compare editbox.seltext to subst(editbox.value,.selstart+1,.sellength) from the form, it returns values which appear to be correct, even though at the control level they are not.

So far, it's been working well.

>>It does, but only if you don't take into account invisible characters, such as CRLF. In my opinion, that alone is a bug.
>
>Those need to be there. If you do a LEN('david' + chr(13) + chr(10) 'marlin') you'd want the CRLF in there too, what if you were doing a Stuff(), or Subsstr() and needed to know those 2 characters were there? Same with this.
>
>>If in this case, you change the value of seltext, it doesn't work - it changes seltext plus some offset.
>
>Try something like this:
>
>
* Add the passed tags to the value where the text is selected
>* Notice how the line feeds are stripped out, they were causeing problems
>lcNewString = tcTag + substr(strtran(.Value, chr(10)), .SelStart + 1, .SelLength) + tcCloseTag
>.Value = STUFF(strtran(.Value, chr(10)), .SelStart + 1, .SelLength, lcNewString)
>.SelLength = len(lcNewString)
>
>I've written HTML editors in VFP before, and this is just a snippet of code from a button like you are describing.
Previous
Reply
Map
View

Click here to load this message in the networking platform