Issue text input between Mac OS and Windows

I’m developing and building under Mac OS. My app is working just fine there. I’ve several text fields that I’ve used the string options “Titlecase”, “Uppercase” and “Lowercase”. This is working as expected on the Mac. Here’s an example.

In the TextChanged event, I have the following:

txt_firstname.text=txt_firstname.text.Titlecase

On the Mac, as I type the text, the first letter of the word is capitalized and the rest forced to lowercase.

When I run the build for Windows, it keeps capitalizing the character just typed and putting it at the front of the text box. If I type the entire name, the text is reversed with the last later typed capitalized. Since these features are listed as supported on all project types and targets, I’d expect it to behave the same on Windows as it does on the Mac.

Am I missing something here?

Use something like LostFocus Event:

Var first_name As String = me.Text
me.text = first_name.Titlecase

I think on windows the event is raised as a character is added (instantly) and may maybe adding a little delay.

1 Like

You could set the selectionstart in your routine, it looks like on Windows it puts the cursor back to the starting position when you set the text:

var startPosition as Integer = me.SelectionStart
me.text=me.text.Titlecase
me.SelectionStart = startPosition
1 Like

This seems like a simple solution and my quick test shows it works fine.

1 Like

I will test this too. Some great suggestions here. :slight_smile:

Thanks Bill! This seems to be the best option for my purposes and works as I’d hoped. It seems to be working fine in Windows and Linux as well as Mac OS.

1 Like