Copy/paste in Text Box

I’m wanting to implement a copy/paste function in an older project.

I’ve played with the simple example in the Example folder and got it to work as desired.

I’ve updated my text field in my project from the older TextField to DesktopTextField but still get the “pop” sound when I try to paste data into the new textfield.

Are there other conditions that need to meet before my text field will accept a paste?

Do you have Copy and Paste items in your window’s Edit menu?

Your Magic Box have to have the Focus… maybe !

Copy/Paste are in the Edit menu. All windows have been converted to Desktop Windows.

Still just “pops” when I try to paste into a DesktopTextbox.

Do I have to convert all textboxes to DesktopTextboxes?

What else?

  • It needs to have the focus, as Emile pointed out.
  • It needs to not be read-only.
  • The character(s) to be pasted must be compatible with the field’s validation mask if any.
  • The count of characters being pasted must be <= the MaximumCharactersAllowed if MaximumCharactersAllowed <> 0.

These are unknow to me.

TextField (one line) and TextArea (plus their Desktop declinaison) are known.

Also, you do not display the code you use to “Paste” nor the Data you want to Paste…

Hey, a lot of unknow stuff; please clarify these and you will get far more (and better) answers.

Example of what you better not do:
TextArea1.Text = "My beautiful text I can paste."

Yes, this is not paste, so imagine you have this text in the clipboard and you wrote:
TextArea1.Text = Clip.Text

AFAIK you don‘t need extra code to enable copy/paste out of the box. Maybe you need to convert your menu bar(s) too that they gave the prefix „Desktop“ otherwise it‘s not compatible (?).

Hi all,

Thank you for your comments and suggestions. This has been an interesting journey that I didn’t document but here goes …

First, a short explanation about why I wanted to do this. The app I build some years ago manages church donations and produces tax receipts at the end of the financial year. Last year I added a feature that made emailing these receipts a option but on using it, manually copying email addresses is error prone. But copying and pasting an address from an email is dead easy and error free.

Somewhere in my stumbling around trying to sort this out I came across a requirement that all my windows to DesktopWindows. OK, no big deal, my app has only 14 windows but most have features use the API and these have minor changes (mostly Open becomes Opening, Close becomes Closing etc). Then it seemed that the MenuBar needed changing. This was a small nightmare as EnableMenuItems becomes MenuBarSelected but the old of referencing Menu items didn’t work. In the I found that
MenuBar2.Child(“EditMenu”).Child(“EditCut”).Enabled = false did compile but readily crashed with nil object exceptions. Getting the MenuBar referenced in the final build wasn’t obvious and is done (for me) in the App settings.

It now works for both DesktopTextboxes and simple TextBoxes and I’m happy. Which step was necessary to get this work I don’t know but suspect it was the MenuBar but I’m not going to experiment to try and work it. Let sleeping dogs lie m’thinks.

Again thank you for your contributions and hopefully this might help someone else in the future.