« Xojo Developer Confer… | Home | Training Day Before X… »

WebTextField autocomplete trouble and fix


There is a problem with WebTextField. On certain browsers the user may have the field being autofilled and no event is triggered, so the Xojo runtime does not notice the change and the text property in code has not the new text.

For that there are two Feedback cases: 30289 and 30875.

Now a fix is possible like this:

dim s as string
s = "document.getElementById('"+TextField1.ControlID+"_inner').onchange = "+_
"function () { Xojo.controls['"+TextField1.ControlID+"'].fireAction(); };"
ExecuteJavaScript s
s = "document.getElementById('"+TextField1.ControlID+"_inner').onpropertychange = "+_
"function () { Xojo.controls['"+TextField1.ControlID+"'].fireAction(); };"
ExecuteJavaScript s


As you see we install onchange and onpropertychange event handlers in javascript and fire the action event for the control which causes the TextChange event to fire later. This way the xojo runtime knows something happened in the textfields. You can run this in a shown event, so the control is setup in the browser and you modify it early.

As far as I got the feedback, it seems to fix the problem here for a client.
11 02 14 - 10:48
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.