Hi,
Is it possible to convert a TextField into upper case automatically.
My users will probably type in lower case - but when they click on the SAVE button, I would like all of the TextFields to be converted to uppercase before they are saved to the database.
I have looked in the Language Reference under TextField, but can not see anything relevant??
You are right. I tend to look at text fields for short amounts of text. 5K looks much more like a Text Area.
I must be limited, I do not see how to use a flag to prevent repeat execution.
But on the other hand, TextChange is not really recurrent. So whenever it happens, me.Text = me.text.Uppercase would just work fine in most cases where the user enters lowercase. Strcomp would be of use to prevent execution when user enters uppercase.
Maybe a flag could be used from Keydown by detecting lowercase. But then if the user pastes lowercase, it would not work…
static flag as boolean
if not flag then
flag = true
me.text = me.text.uppercase
flag= false
end
Just don’t use static in subclass code because it’s shared across all instances and could produce unpredictable results. Make it a property instead. Static is probably fine in event code in the window.
First, I tested the code I posted above, and there is NO crash.
Then, WHERE do you set alreadyChanging besides in your short piece of code that makes sure alreadyChanging is always false ? As a matter of fact, this code in TextChanged executes ONLY when text is changed. So by hypothesis, only when text is changed. Your code has absolutely no effect.
There has apparently been a change in behavior since earlier versions of Xojo/Real Studio. In past versions, any change in the text would trigger the TextChange event, so changing the text within TextChange would cause TextChange to fire again which would cause another change in the text leading to another TextChange, etc.
It appears TextChange no longer does that, as Michel has pointed out and I’ve just tested, so he’s right, that flag code is no longer needed.