Any CLIPBOARD for WEB2

Has anyone solved the problem of using an equivalent to the Clipboard object in Web2?

To be able to take values that are in the clipboard or send them to it using a web browser.

For example:

Var c As New Clipboard
c.Text = "The Quick Brown Fox outran the Lazy Dog"
c.Close

Isn’t that a security risk? Other than that, you would have to use the Web SDK and implement some javascript to read the clipboard and send it to your web app.

I want to get text out of the web page. It is not towards the system.

I only found a solution from Jeannot Muller (shared two years ago). But I want to know if there are any options.

I’m not sure I understand. Do you want your web page (in the browser) to grab the contents of the clipboard, wherever they came from, and send it to your app? Or do you want the web page to grab the contents of the clipboard and stuff it in a text field on that page? Or do you want the user to highlight some text on the web page and send it to your app so you can act on it?

None of the mentioned options.

My system shows a grid with information (webListBox). I want the user to select a row and copy it to the clipboard.

Clipboard access in browsers is tricky at best. The problem is that it’s implemented to varying degrees in the different browsers, but also that it requires that the user actually press the keys and that the action of accessing the clipboard happen within that event loop. Not to mention that you have to override the behavior of CMD/CTRL C, V and X.

You can see a summary of the issues on this page:

Thank you, Tim and Greg. I appreciate the responses received.

The only solution is the one shared by Jeannot Muller two years ago. Require a click-event to click on the button and copy the value to the user clipboard.

That’s what Greg is saying: for very good security reasons, the browser’s ability to place data on the user’s clipboard only operates when it is run in response to a user-initiated action (right-clicking and choosing an action from a popup menu, for example). It won’t work when triggered by your code alone.

1 Like

I’ll give you the solution I found.

From this comment, I am very grateful to Jeannot Muller for sharing his problem and solution. It works fine.

There are times when the user requests something that this may not be able to do for security reasons. But it makes sense to ask for it to avoid the need to download all the information as an Excel file.

https://xojo.jeannot-muller.com/teccclipboard-xojo-web-plugin-307688902422

2 Likes