开发者

Developing FireFox extension, clipboard

I want to listen on an event (clipboard event ?) in order to alter the clipboards content.

Actually i did no开发者_运维技巧t find out how i can grab the clipboards content after it has been filled (using ctrl+c).

I tried to redefine the shortcut ctrl+c, but this way i only get what was in the clipboard before i pushed the shortcut.

Where do i need to hook me in, which event? Any suggestions?


I found out how to catch events in Firefox. The following code snippet shows how to listen for crtl+c/meta+c. The function dehyphenate_clipboard gets called when the combo ctrl+c is being pressed:

on_key_down : function(e)
{
    if
    (
        (mac && e.metaKey && e.keyCode == 67) || // Mac : Meta-C
        (!mac && e.ctrlKey && e.keyCode == 67)
    )
    { __er__.dehyphenate_clipboard_on_keyup = true; } // set flag
},

on_key_up : function(e)
{
    if
    (
        __er__.dehyphenate_clipboard_on_keyup ||
        (e.ctrlKey && e.keyCode == 67)  // Ctrl-C
    )
    {
        __er__.dehyphenate_clipboard_on_keyup = false; // reset flag 
        __er__.dehyphenate_clipboard();
    } 
},
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜