Pasting in textfield

Hello,
I have written a windows program where I have a few Textfields on them. They are all setup the same way with nothing special, just a code so when the user presses enter, it will move to the next field. The problem that I am having is that on some of the fields (not all), when I want to paste some text (just text) using crtl-V, it shows a square.

Has anyone ran into this problem?

Are the text elements that show as squares special characters? Have you tried changing the font used in the text you are copying?

Is this standard under Windows ?

using crtl-V, it shows a square
Isn’t it a black lozange with a ? inside ?
If so, this is called replacement character and only means “the used font does not have this character defined”

In this case, set the Encoding to UTF8 (if this does not works, set it to Windows 1252 - I think this is the code, check with the LR).

A screen shot with the behavior (Windows allows you to do a full screen screen shot or a user selected area screen screen shot, then paste in Edge) is the best idea to get a good guess about the trouble.

From where your text comes ?

Perhaps it’s the line feed character copied with Ctrl-C

I open up notepad and type “THIS IS A TEST”, then I highlight and copy to clipboard. Then, on my application, I clicked on the field that I want to paste it to and press CRTL-V, I get what you see on the screenshot (a square). If I paste it to the “Job” field, it works fine



1

The textfields are setup the same. Here I show you the only thing I do on both of them.


  • Create a new empty project
  • Copy a control that doesn’t work and paste it into Window1 on the new project
  • Copy a control that works and pate it into the Window1 on the new project
  • Run the project, does it still happen?
  • If Yes, post the project here, if no, let us know
  • If the paste doesn’t work then you have a Super that you also need to copy across (or check that for additional code that could be causing the problem)

As far as I recall, Notepad allow you to set the encoding.

Also, if you copy the End Of Line Character (select the whole line ) and if you have pressed Return or Enter…

Try to copy only “THIS IS A” / set an encoding (UTF8 for example).

Julian answer is very good.

i guess with return false you forbid all other key input at keydown event.

It should not do anything. Returning false means the event is not handled by the code.

Check to see if you have a mask or some other kind of restrictions set on the text field as I’ve seen those cause corruption when pasting.

1 Like

Thank you guys, problem was the Mask like kevin g mentioned. I had a mask to make it all uppercase in those fields. I removed and used the .uppercase in the lost focus instead.

This did work in Realbasic and was broken at some point afterwards. I logged a bug 4 years ago when we found it:
https://tracker.xojo.com/xojoinc/xojo/-/issues/52506