App erasing the clipboard when it quits

I have a listbox on a window. The user selects a name and the change event puts a code on the clipboard that will pasted into a different program. This works. But I would like the user to be able to select the name, hit return or click a button to quit the app and then go back to the other app to paste. Quitting the app erases the clipboard. Thisis not essential, but convenient.

If I select the name, paste the code and then close the app, I can continue pasting the code, it is not erased after it has been pasted one time.
So, is there any way to “paste” in code so that theclipboard won’t be erased?

Also I have noticed that many, but not all, Linux apps have this same erasing “feature”. So I am guessing that there is some way around it.

I am putting the text on the clipboard with:
Dim cb as new clipboard
cb.text = “thecode”

I also tried putting it on the clipboard with xclip:
Dim sh as new shell
sh.execute echo -n “the code” | xclip -selection clipboard

This causes the app to hang until the code is pasted into the other program, which would work except that the user couldn’t change his mind and select another name.

Any ideas?

Don Jungk,
Xojo 2016r4.1, Mint 18.3, MATE.

That is an X11 (and X10 if you’re that old) thing. Basically, when you copy something to the clipboard, the copy action just notifies the windowing system of the window that has content available - no copy actually exists in RAM yet. Only after the target application requests that content via a paste, does it get the content from the source window/application.

The used to kill us in the documentation arena with Framemaker on SunOS and SCO Unix. If you didn’t paste your copy to a “placeholder” app, you would lose your copy when moving from one document to another (since you could only have one open at a time).

I figured it was something like this although I didn’t knowthe details. So, Is there a way to request that copy in code? Or in a hidden helper app that runs with the main one?
Thanks for your help,

Just brainstorming, but try this -

Add a TextArea to your app and hide it. When you copy, automatically paste it into that hidden TextArea. I don’t believe that it must be a different process that receives the paste.