1. #11
    Sencha Premium Member
    Join Date
    Dec 2007
    Posts
    45
    Vote Rating
    0
    bernd01 is on a distinguished road

      0  

    Default


    Hi srt_spaeth,

    Thanks for the great plugin! Works like a charm.

    I guess, I might have found a typo in the class Ext.ClipBoard:
    PHP Code:
            setData: function(dataObjidentifierString){

                if(
    typeof identifieSring != 'undefined') {

                    
    lastInExtCopiedString identifieString;

                }

                
    dataObject dataObj;

            }, 
    I guess identifieSring should be identifierString

    Thanks,
    Bernd

  2. #12
    Sencha User
    Join Date
    Dec 2008
    Location
    Mainz
    Posts
    241
    Vote Rating
    1
    crp_spaeth is on a distinguished road

      0  

    Red face


    Hi bernd01,
    Thank you for your attention and reporting this typo.

    The bad news is that fixing this typo will break the whole mechannisem.
    Since i am using a Textareas value property to bypass the content to the Clipboard but using an Iframes innerHTML property with designmod = on to bypass content from the Clipboard back to the Ext Plugin the copied and the pasted value differ even if the should be the same in a few cases.

    This is happening cause the Browser will parse the sting you try to insert into the Iframe as a HTML. So if you try to past a text with a break in it "testvalue1 testvalue2 \n testvalue3 testvalue4\n", like i do in the Grid example you will end up with something like this:
    "testvalue1 testvalue2<br> testvalue3 testvalue4<br>"

    So if you compare those two strings in the getData function you will end up getting back the pasted string and not the dataObject. Cause of the typo you just found bernd2 and the other typo in the getData function you will end up getting the last copied Ext.Dataobject even if the user copies a text from another Application.

    Maybe some of you got an idea how to solve this problem. Is there a property or method i dont know yet to get a javascript string from a dom element?

    The other solution would be to use a Textarea to bypass from the clipboard but this means a few other thinks I was thinking about to implement will not be possible anymore since you cant Paste the same stuff into a Textarea like into an Iframe...

  3. #13
    Sencha Premium Member
    Join Date
    Dec 2007
    Posts
    45
    Vote Rating
    0
    bernd01 is on a distinguished road

      0  

    Default


    Hi!

    Thanks for your reply. To be honest, I think in general I understand how your use the browser trick, however in detail I am not really sure...

    I corrected the typo in my code and it is still working for my example (the grid). Not sure what is different...

  4. #14
    Sencha User
    Join Date
    Dec 2008
    Location
    Mainz
    Posts
    241
    Vote Rating
    1
    crp_spaeth is on a distinguished road

      0  

    Default


    Did you change the getData methode too?

    I think I will reimplement the Bypass for the Paste process with an Textarea to avoid the parse Problem I came up with.

  5. #15
    Sencha Premium Member
    Join Date
    Dec 2007
    Posts
    45
    Vote Rating
    0
    bernd01 is on a distinguished road

      0  

    Default


    Yes, I have overwritten that too - still working.

    However, I faced another javascript error. I could eliminate that by overwriting your Ext.Element.setCaretText function like this:
    PHP Code:
    /*
     * override: setCaretText, because 'text' is not given in:
     * Ext.plugins.CopyPasteable:copyHandler
     *     elfly.setCaretText();
     */
    Ext.override(Ext.Element, {    
        
    /**
         * overrides the currently selected Text with an other text
         * @param {String} text
         */
        
    setCaretText : function(text){
            var 
    this.getCaret(), this.domi.value;
            if(
    typeof s == 'undefined') {
                return;
            }
            if (
    text)
            {
                
    i.value s.slice(0o.start) + text s.slice(o.end);
                
    this.setCaret(o.start += text.lengtho.start);
            }
            else
            {
                
    i.value s.slice(0o.start) + s.slice(o.end);
                
    this.setCaret(o.start += o.start);
            }
        }
        
    }); 
    I am not sure if anybody is interested in the next code part. It allows you to enable/disable the keymap with a toogle button. In that way the user can choose between using your cool plugin or the standard copy/paste behaviour (unfortunatly I cannot find the forum post anymore for that).
    Code for enable/disable keymap:
    PHP Code:
    Ext.override(Ext.plugins.CopyPasteableGrid, {
        
    plugin_name'GridCopyPasteClipboard',
        
    is_keymap_enabledtrue,
        
    copy_paste_keymapfalse,
        
        
    /*
         * overwrite in order to by default disable keymap
         */
        
    render: function(){        
            
    this.wrapper Ext.DomHelper.append(this.client.el, {
                   
    tag'div',
                   
    children: [{
                        
    tag'textarea'
                   
    }, {
                           
    tag'iframe',
                           
    nameExt.id(),
                           
                           
    frameBorder'1',
                           
    srcExt.isIE Ext.SSL_SECURE_URL "javascript:;"
                           
                   
    }
                   ],
                   
    //'class': 'x-hidden',
                   
    style'height:0; width:0; overflow:hidden'
           
    });
                 
           
    //this.wrapper.appendChild(iframe);
            
           
    this.bypassIframe this.wrapper.childNodes[1];
           
           
    this.initFrame();
           
    this.bypassTextarea this.wrapper.firstChild;
           
           
    // map the keystrokes ctrl+c and ctrl+v to its hanlders
           
           // FIX doesn't get fired if a normal text in the Panel was selected 
           // before presing ctrl+(v|c) 
           
    this.copy_paste_keymap = new Ext.KeyMap(this.client.el, [{
                
    key'c',
                
    ctrltrue,
                
    fnthis.copyHandler,
                
    scopethis
           
    },{
                
    key'v',
                
    ctrltrue,
                
    fnthis.pasteHandler,
                
    scopethis
           
    },{
                
    key'x',
                
    ctrltrue,
                
    fnthis.cutHandler,
                
    scopethis
           
    }]);
           
           
    //disable keymap by default
           
    this.disable(); 
        },
        
        
    /*
         * enables the keymap
         */
        
    enable: function(){
            
    this.copy_paste_keymap.enable();
        },
        
        
    /*
         * disables the keymap
         */
        
    disable: function(){
            
    this.copy_paste_keymap.disable();
        }
    }); 
    Code for the standard copy/paste behaviour (which forum post I unfortunately don't find anymore):
    PHP Code:
    .x-selectable, .x-selectable * {
        -
    moz-user-selecttext!important;
        -
    khtml-user-selecttext!important;
    }

    if (!
    Ext.grid.GridView.prototype.templates) {
        
    Ext.grid.GridView.prototype.templates = {};
    }
    Ext.grid.GridView.prototype.templates.cell = new Ext.Template(
        
    '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable {css}" style="{style}" tabIndex="0" {cellAttr}>',
        
    '<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>',
        
    '</td>'
    ); 
    Cheers,
    Bernd

  6. #16
    Ext User
    Join Date
    Jul 2009
    Posts
    2
    Vote Rating
    0
    blackhorn is on a distinguished road

      0  

    Default Bug

    Bug


    Hi,
    Congralutions! Nice Plugin, very usefull; but there is a probleme with ExtJS 3.0.0
    All works just only one thing don't want work!
    When I copy there is data and a string representation
    With CTRL+C no problem
    but with a action and a copyToClipboard there is data but not a string representation?
    Can you solve it? or give us a way to solve it?
    Thanks
    Have a nice day

  7. #17
    Sencha User
    Join Date
    Dec 2008
    Location
    Mainz
    Posts
    241
    Vote Rating
    1
    crp_spaeth is on a distinguished road

      0  

    Default


    You ask for the possibilty to have a string representation in the nativ system clipboard by pressing a button in Extjs?


    My Plugin uses a neat workaround to deal with this by bypassing data into the clipboard as descriped in the first post. The Bypass uses the Browsers Nativ Copy Command which gets Fired if the User press CTRL+C.

    I know there is a way to write Data in the System-Clipboard using Javascript in the Internetexplorerer, but I think there is no way to access it in Firefox and Safari.

    There is another missing thing which is not supported yet. The Ext.Clipboard will not work if the User uses the Internet-Explorer Menu Funktion Edit-->Copy.

    I think I have an Idea to deal with that as well but therefore Ill need an Focusable Panel as descriped in the Following thread.

    If you would like to see a better Implementation of this Plugin you may "+1" my Featurerequest in this thread...

    http://extjs.com/forum/showthread.php?t=73555

  8. #18
    Ext User
    Join Date
    Jul 2009
    Posts
    2
    Vote Rating
    0
    blackhorn is on a distinguished road

      0  

    Default


    Thanks for your quick reply.
    There is another (proper) way to make a copy system like yours works?
    I saw many page with a swf file but i can make it works!
    Thanks !

  9. #19
    Ext User
    Join Date
    Sep 2009
    Posts
    7
    Vote Rating
    0
    hellogavin is on a distinguished road

      0  

    Red face


    I cannot see the demo right now!

  10. #20
    Sencha Premium Member
    Join Date
    May 2007
    Location
    USA
    Posts
    73
    Vote Rating
    0
    notjoshing is on a distinguished road

      0  

    Default just copying?

    just copying?


    For some applications, I want to send specific text to the clipboard without the user needing to press keys. For instance, clicking on a "get link" control. I'm not sure how I'd do something like that using your model; it seems to need an element to drive off of to get the text. Am I missing something?

    Thanks,

    Josh
    Using:
    ExtJS 2.2, 3.2, 4.0.7a
    WinXP SP3
    FF10,6; IE6; IE8; Safari