Copy to clipboard from WebListBox

What event must I trap in order to copy the contents of a WebListBox to the clipboard?

You cannot trap system events in Web.

How would I trap ^C or Apple C

Keypressed

Websites do not have access to the clipboard for security.

waa!!!?? No copy paste? Why is that a ‘security’ risk?\
I copy and past from web pages ALL the time.

Do you really want any old website to putting arbitrary data on your clipboard? The clipboard should be user initiated NOT website initiated. Thus, we have no access to end users clipboard via web apps.

What am I not understanding?

See this?! @Brian O’Brien waa!!!?? No copy paste? Why is that a ‘security’ risk.
I just copied and pasted it from above to here.

Was it my understanding that this forum web site was written in Xojo?

If you copied and pasted it then yes, YOU, the person sitting behind the computer, did the copy and paste. The website did nothing on the server side to initiate it.

If a website can put data on a clipboard that also means they could grab information from he clipboard. Imagine you copied your bank account information (for whatever reason) and a hacked website just grabbed that data. It might take a couple of million tries to get useful information but it’s still a security risk. This is why web browsers run in sandbox mode so malicious websites can’t do stuff like this.

It’s possible (never tried it) that you could get Javascript (running on the client side) to access the clipboard. I found this article from 2009 https://brooknovak.wordpress.com/2009/07/28/accessing-the-system-clipboard-with-javascript/ I suspect modern browsers won’t allow it but you can try it.

No. It’s powered by esoTalk. I believe it’s php (but could be wrong).

And remember, a Xojo web app runs on the server. Very little ‘code’ runs in the users browser. In reality it simply sends events back to the server for processing and then sends back whatever html that’s needed for the browser.

ALL processing is done on the server. None of it on the (dumb) web browser.

I’m thick. I don’t get it. Why can’t the user copy text that is in a WebListBox to his clip board?
Is it something in my code that I’m not doing correctly?

The user CAN as long as they select the text themselves and imitate the copy themselves. You, the programmer, can’t programmatically add it to his clipboard for them.

Well have I found a bug then? I mean this should this have worked?
There were multiple rows of the web list box selected and I did edit / copy from the browser.
Then I went to excel and pasted and got some other text that i had copied to the clip board earlier.

User initiated copy and paste events work.
Your app cannot initiate the copy or paste event.

From your initial post I thought you wanted your app to initiate the copy event (which it cannot do)

So why didn’t it work?
If there is nothing I was suppose to do… It should have worked.
Has anyone else tried to copy the contents of a weblistbox to their clipboard and succeeded?

[quote=246239:@Brian O’Brien]So why didn’t it work?
If there is nothing I was suppose to do… It should have worked.
Has anyone else tried to copy the contents of a weblistbox to their clipboard and succeeded?[/quote]

You don’t seem to grasp the elementary fact that a Web App is not executing on the user machine, but simply shown by the browser. Your app is merely a guest of another app, not a native app.

Access to the clipboard of the user machine is just as impossible as accessing the apps on the phone of someone you called.

What do you want to achieve ?

Michel, I don’t think Brian O’Brians question is at all complicated. What he is saying is he has selected n rows from a weblistbox and wants to copy them from the browser to excel. I assume the issue is and why it is not working that the weblistbox is a control on the page not rendered HTML. If your list was rendered in HTML then you could select the text and copy to your clipboard. By you selecting copy from your browsers menu, I don’t think it will be aware of the selected rows within your web list control and therefore won’t copy them.

Brian, what everyone is telling you is that you cannot trap a CTRL C event and then put data on the clipboard programatically. If this was available to you then what is stopping you visiting a malicious site and carrying out a copy and the website putting malicious data on your clipboard.

The issue here is that the selection shown by the WebListBox is simply a styling effect.

BTW the Weblistbox is just an HTML Table, so it is indeed possible to select it, but that requires placing the cursor above and off it, then drag the mouse down to the bottom while holding the button.

The resulting selection is nothing like the usual dark blue used to show selection, but a lighter shade of blue showing only over text.

Another approach would be to copy all the WebListBox content into a TextArea, then select all the content in code with

self.ExecuteJavaScript( "$(document.getElementById('"+TextArea1.ControlID+"').getElementsByTagName('textarea')[0]).select();")

Important : this is using JQuery, so this must be added to App.HTMLHeader :

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

I picked the code above for a TextArea from one of my projects. It is probably possible to select a WebListBox content with a similar method, but that means writing a whole JavaScript routine code to traverse the whole table and select each td element. Note that select() can be used only in a TextField or TextArea. Selecting the rows will require setSelectionRange. See
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/setSelectionRange

In short, this is a whole lot less simple than SelStart and SelLength in Desktop.

Can someone simply confirm whether it is possible for the user, with his mouse, to copy text from a WebListBox or not? That would tell Brian whether he has a problem with his webpage or if there is some limitation with WebListBox. A clear, simple answer would be appreciated.

In the meantime Brian, create a simple web app with nothing but a weblistbox and no code other than to populate some text in the listbox, and try it there.

[quote=246356:@Tim Hare]Can someone simply confirm whether it is possible for the user, with his mouse, to copy text from a WebListBox or not? That would tell Brian whether he has a problem with his webpage or if there is some limitation with WebListBox. A clear, simple answer would be appreciated.

In the meantime Brian, create a simple web app with nothing but a weblistbox and no code other than to populate some text in the listbox, and try it there.[/quote]
I’ve done that… In shown

Sub Shown() ListBox1.InsertRow(0, "Hello", "World") ListBox1.InsertRow(1, "Copy", "me") End Sub

Ran it and selected the two rows, from the browser, copy.
Into excel paste… Nothing… Just the last contents of the clipboard.

But from what I can gather this is intended behaviour.