Hi all,
I've a problemi with copy/paste in Midas. I've configured the preferences of Mozilla (1.4) for the use of the clipboard via UniversalXPConnect:
user_pref("signed.applets.codebase_principal_support", true);
user_pref("capability.principal.codebase.p0.granted", "UniversalXPConnect");
user_pref("capability.principal.codebase.p0.id", "http://www.mysite.com/");And using the clipboard function found on XulPlanet:
http://xulplanet.com/tutorials/xultu/clipboard.html http://www.mozilla.org/xpfe/xptoolkit/clipboard.html
Now my problem is: on the "paste" event I have to:
- get the content of the clipboard _as text_ - insert the text in the current selection of the editor;
I've an IFRAME with "contentEditable" set to "on" and I now use Ctrl+V to paste the content of the clipboard on the document inside the frame.
The problem is: when Ctrl+V is pushed the content of the system clipboard is pasted _before_ the event "onkeydown" is intercepted by my event handler. So the content of the clipboard is pasted two times, the first in full HTML and the secondo in simple text!
I have to prevent the default action of the "Ctrl+V", and then execute my "copy text from clipboard and paste" action.
Who can help me?
This is the code. I've added the listener to the HTML elemet of the coument inside the IFRAME:
myDocument.documentElement.addEventListener("keydown", onKeyDown, true);
so the event listener is used with capture = true.
Now the code of the listener:
function onKeyDown(event)
{
if ((event.keyCode == 86 && event.ctrlKey) ||
(event.keyCode == 45 && event.shiftLeft))
{
// insert the clipboard text
insertClipboardText(); event.preventDefault();
event.stopPropagation();
return false;
}
}The problem is that the HTML of the default action is performed _before_ the listener is executed, so the result is:
- first the HTML is pasted;
- then onKeyDown listener is invoked and the content of the clipboard is pasted again with only the text.
Thanks, Gaetano
_______________________________________________ mozilla-editor mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-editor
