Hi,
1. I want to update few variables when any of the toolbar button (like bold, italic etc) is clicked. I'm unable to trap 'click' event on any of these buttons. Could somebody give me an example when clicking on 'bold' button would also pop up an alert box?
2. How can I trap 'paste' event?
I've googled a lot and searched this forum but couldn't find any solution. Any pointer would be really helpful.
Thanks.
1. I want to update few variables when any of the toolbar button (like bold, italic etc) is clicked. I'm unable to trap 'click' event on any of these buttons. Could somebody give me an example when clicking on 'bold' button would also pop up an alert box?
2. How can I trap 'paste' event?
I've googled a lot and searched this forum but couldn't find any solution. Any pointer would be really helpful.
Thanks.
Re: How to know which button is clicked
1. You can use afterCommandExec event:
Example:
editor.on('afterCommandExec', handleAfterCommandExec);
function handleAfterCommandExec(event)
{
var commandName = event.data.name;
// For 'bold' commmand
if (commandName == 'bold')
alert("Bold button pressed!");
}
2. You can use the same method as above i.e. capture afterCommandExec and check for paste and pasteText event when the Paste and PasteText buttons are pressed. On the other hand, you can use onKeyDown to check for Ctrl+V combination.
Cheers,
Kristin
Re: How to know which button is clicked
Sweet. This was perfect. Thanks Kristin.
I don't have paste buttons in my toolbar. Pasting via Ctrl+V is working fine. But paste via mouse right click paste option is not working with paste/pasteText. One more thing, just to let you know, on pasting via mouse another window pops up and says pasting is not allowed in your browser so paste here.
Re: How to know which button is clicked
CKEDITOR.plugins.add( 'adico',
{
init : function( editor )
{
// afterCommandExec
editor.on( 'afterCommandExec', function(event)
{
var commandName = event.data.name;
// For 'bold' commmand
if (commandName == 'bold')
alert("Bold button pressed!");
});
}
});
I basically want to grab CTRL+V data and add few text to it and then add it to the editor.
Thanks a lot in Advance
Re: How to know which button is clicked
I'm trying to identify clicked buttons too. I used ngthuydiem's solution and worked like charm for most buttons, but i found out that buttons that show up a pick-up layer such as font-color, bg-color, font-size... doesn't trigger afterCommandExec event.
Is there any way to get the click event for these specific controls?
thanks