Hi all, this is my first post so.. glad to be here and greetings to all!
My problem:
The event "onSelectionChange" is fired every random keypress with IE. No problems with Firefox instead.
My question:
Is there a way to trap every keypress with the event onSelectionChange in IE ?? (or with any other method..)
Thanks to all
cheers
Adriano
My problem:
The event "onSelectionChange" is fired every random keypress with IE. No problems with Firefox instead.
My question:
Is there a way to trap every keypress with the event onSelectionChange in IE ?? (or with any other method..)
Thanks to all
cheers
Adriano
Re: Trap EVERY keypress with IE by onSelectionChange event
There is no event for key presses. You can easily achieve this by watching the "OnAfterSetHTML" event on the editor, and then attaching your custom handlers to the standard keypress DOM event in the editor area document.
You may check the JavaScript API docs, as well as the sample08.html file for some very basic API usage information.
Frederico Knabben
CKEditor Project Lead and CKSource Owner
--
Follow us on: Twitter | Facebook | Google+ | LinkedIn
Re: Trap EVERY keypress with IE by onSelectionChange event
Thanks... but...
might i ask for some lines of example code??? I have used the PHP integration of the FCKEditor
I have difficulty attaching the DOM keypress event to the editor...
Thanks!
Adriano
Re: Trap EVERY keypress with IE by onSelectionChange event
EUREKA, IT WORKS!!!!!
Thanks to all, your help was invaluable!!!
Adriano
function GetLength()
{
// This functions shows that you can interact directly with the editor area
// DOM. In this way you have the freedom to do anything you want with it.
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
// Get the Editor Area DOM (Document object).
var oDOM = oEditor.EditorDocument ;
var iLength ;
// The are two diffent ways to get the text (without HTML markups).
// It is browser specific.
if ( document.all ) // If Internet Explorer.
{
iLength = oDOM.body.innerText.length ;
}
else // If Gecko.
{
var r = oDOM.createRange() ;
r.selectNodeContents( oDOM.body ) ;
iLength = r.toString().length ;
}
//alert( 'Actual text length (without HTML markups): ' + iLength + ' characters' ) ;
$('#counter').val(iLength);
}
function FCKeditor_OnComplete(editorInstance)
{
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
// Get the Editor Area DOM (Document object).
var oDOM = oEditor.EditorDocument ;
if ( document.all ) // If Internet Explorer.
{
oDOM.attachEvent("onkeypress",GetLength)
}
else
{
oDOM.addEventListener("keypress",GetLength,false);
}
//editorInstance.Events.AttachEvent( 'OnSelectionChange', GetLength ) ;
}
Re: Trap EVERY keypress with IE by onSelectionChange event
This might be a very basic question but I want to trigger event (onAfterSetHTML) on FCKeditor instance on standard keypress DOM event in the editor area document.
Whether it is possible or not ??
The following statment raised the above question in my mind.
"There is no event for key presses. You can easily achieve this by watching the "OnAfterSetHTML" event on the editor, and then attaching your custom handlers to the standard keypress DOM event in the editor area document."
Can you please throw some light on this statement.. ???
I saw the sample codes but those are not giving any hint to me..
My question is How to convey standard keypress DOM event in the editor area document to FCKEditor instance so that it will call onAfterSetHtml ???
I am pasting some part of sample code that I tried...
///// Code to listen to Standard DOM keypress event
if(document.all){
//alert("This is IE event");
oDOM.attachEvent("onkeydown",zkFCKed.onkeypressIE(A));
}
else
{
alert("This is firefox event");
oDOM.addEventListener("keypress",zkFCKed.onkeypress(A),false);
}
onkeypress= function(e) // e = event
{
if(e.which=32)
///// Call function onaftersethtml here
}
onkeypressIE= function(e) // e = event
{
if(e.which=32)
///// Call function onaftersethtml here
}
onaftersethtml = function(A,e){ //////// Call back on onAfterSetHtml
//// Here A is an instance of FCKeditor
}
It will be great to have ur help
Thanks in advance..