首页 > 解决方案 > Del key doesn't fire in WebBrowser-hosted CKEditor

问题描述

I have a WebBrowser-hosted CKEditor instance, but pressing the Del key doesn't do anything.

I tried this to get through thre problem:

In my WebBrowser-derived class:

Protected Overrides Sub OnPreviewKeyDown(e As PreviewKeyDownEventArgs)
    MyBase.OnPreviewKeyDown(e)
    If e.KeyData = Keys.Delete Then
        Document.InvokeScript("pressDelete")
    End If
End Sub

In my HTML page that loads CKEditor:

<script type="text/javascript">
    function pressDelete() {
        return CKEDITOR.instances.myeditor.fire('key', { keyCode: 46 });
    }
</script>

and

<script type="text/javascript">
    function pressDelete() {
        return CKEDITOR.instances.myeditor.document.fire('key', { keyCode: 46 });
    }
</script>

and

<script type="text/javascript">
    function pressDelete() {
        return CKEDITOR.instances.myeditor.execCommand('delete');
    }
</script>

The first script raised a Script Error; the other two did nothing.

The case is, the rich text editor I intend to host in my Winforms application is lame if pressing Del doesn't work.

标签: javascriptvb.netckeditorckeditor4.x

解决方案


推荐阅读