I got this code from web its still not working is there any change i should
make to run and copy text to clipboard.

public static native void copyFrom(String mytext) /*-{
        if (window.clipboardData)
        {
        // IE
        $wnd.window.clipboardData.setData('text', mytext);
        // Netscape
        }
        else if (window.netscape)
        {

        netscape.security.PrivilegeManager.enablePrivilege
('UniversalXPConnect');
        var clip =
        components.classes['@
mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;

        //
        var trans =
        Components.classes['@
mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;

        //
        trans.addDataFlavor('text/unicode');

        //
        var str = new Object();
        var len = new Object();
        var str =
        
Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsS
tring);

        var copytext=mytext;
        str.data=copytext;
        trans.setTransferData("text/unicode",str,copytext.length*2);
        var clipid=Components.interfaces.nsIClipboard;
        if (!clip) return false;
        clip.setData(trans,null,clipid.kGlobalClipboard);
        }
        alert("Following info was copied to your clipboard:\n\n" + mytext);

        }-*/;


-harry

2009/3/24 Harish Nair <[email protected]>

> Hi Kevin,
>
> This is not working in FF where as its working very well in IE. Please
> advice me how to do it on FF as the site is going to run on that.
>
> -
> Harry
>
>
> 2009/3/24 Kevin Tarn <[email protected]>
>
>> It was tested in IE and Firefox. I am not sure whether it works on Chrome
>> or Webkit.
>>
>> Kevin
>>
>>
>> On 3/24/09, Dmitry Sterinzat <[email protected]> wrote:
>>>
>>>
>>> Does it work only for IE or it's crossbrowser code?
>>>
>>> 2009/3/24 Kevin Tarn <[email protected]>:
>>>
>>> > You can try below JSNI methods:
>>> >     public static native void
>>> copyFrom(com.google.gwt.user.client.Element
>>> > element) /*-{
>>> >     $wnd.window.clipboardData.setData('text', element);
>>> >     }-*/;
>>> >
>>> >     public static native void
>>> pasteTo(com.google.gwt.user.client.Element
>>> > element) /*-{
>>> >     $wnd.window.clipboardData.getData(element);
>>> >     }-*/;
>>> >
>>> > Kevin
>>> >
>>> > On 3/24/09, Harry <[email protected]> wrote:
>>> >>
>>> >> Hi,
>>> >>
>>> >> My project is that user is enabled to copy the content of a text box
>>> >> and paste it on another form using 'Copy' button. Please advice how to
>>> >> do it as GWT is not support copying to system clipboard.
>>> >>
>>> >> Please help its important.
>>> >>
>>> >> Thanks
>>> >>
>>> >> Harry
>>> >>
>>> >
>>> >
>>> > >
>>> >
>>>
>>>
>>> >>>
>>>
>

--~--~---------~--~----~------------~-------~--~----~
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