On 24 mar, 23:51, Chris <[email protected]> wrote:
> Hi all,
>
> I've been playing around with the ZeroClipboard 
> (seehttp://code.google.com/p/zeroclipboard/) but I did not manage to get
> it to work as of now. After having tried out different approaches /
> solutions from other users (for example 
> herehttp://code.google.com/p/zeroclipboard/wiki/IdeasAndSuggestions), I'm
> now asking you guys. =)
>
> I want to copy a calculated value *from within my GWT-application* to
> the clipboard so that I can use that value anywhere else using Ctrl-v
> (that's what ZeroClipboard is all about right? ;-) )
>
> I therefore put the corresponding code into my host html file
> (Application.html) of my GWT-app:
> <html>
>   <head>
>     <meta http-equiv="content-type" content="text/html;
> charset=UTF-8">
>     <title>Application</title>
>
>     <script type="text/javascript" language="javascript"
> src="ZeroClipbaord.js"></script>
>     <script language="JavaScript">
>         function copy() {
>                 var clip = new ZeroClipboard.Client();
>                 clip.setText('Copied!!!');
>                 clip.glue( 'buttonId' );
>         }
>         </script>
>     <script type="text/javascript" language="javascript"
> src="GWTServlet.Application.nocache.js"></script>
>   </head>
>
>   <body>
>     <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
> style="position:absolute;width:0;height:0;border:0"></iframe>
>   </body>
> </html>
>
> My corresponding Java source-code looks like this:
> public class Application implements EntryPoint {
>
>   /**
>    * This is the entry point method.
>    */
>   public void onModuleLoad() {
>           FlowPanel table = new FlowPanel();
>
>           table.getElement().setId("FlowPanel");
>
>           Button button = new Button("ClickMe to copy to clipboard");
>           button.getElement().setId("buttonId");
>           button.addClickListener(new ClickListener(){
>
>                 public void onClick(Widget arg0) {
>                         copyInJava();
>                 }
>
>           });
>           table.add(button);
>
>           RootPanel.get().add(table);
>   }
>
>         public native void copyInJava() /*-{
>             $wnd.copy();
>         }-*/;
>
> }
>
> ZeroClipboard works just fine when used in plain HTML to copy contents
> to the clipboard but I did not manage to get it to work from inside a
> GWT-application.
>
> I also used FireBug to debug and apparently there is some issue when
> creating the ZeroClipboard.Client() object. Nonetheless, when I run it
> in plain HTML, everything is fine so I assume that the issue is due to
> the fact that I'm using a GWT-app to get the job done.
>
> Does anybody have suggestions what the problem might be?

My understanding of ZeroClipboard is that your copy() function should
be called *prior* to clicking the button, so that ZeroClipboard can
overlay a transparent Flash movie over the button; when you click the
button, you actually click the Flash movie which copies the given text
into the clipboard (that's click-jacking).

So with your code, on the first click you "install" the ZeroClipboard
client and starting with the second click only you copy the text to
the clipboard.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to