This is the discussion forum for the HtmlEditor. See also the
HtmlEditor home page, where you can download the control, and the
Documentation Wiki, a collaborative project for documenting the control.
Re: one dumb question
Posted by: Tim Anderson
Date: Monday, 18-Nov-2002, 08:02:00
As regards HtmlKeyPress, that's my fault. This was first implemented so that it
a) only works in Design (Edit) mode and
b) only fires for Ctrl-... combinations (where ... stands for any key)
You can change this easily. You need to modify the PreHandleEvent method. If you look at the block beginning:
you'll see that InvokeHtmlKeyPress is only called for Ctrl combinations, and even then only when not one of the explicitly handled ones like Ctrl-C. We did this to support shortcut entry of particular HTML content. If you want it to fire on every keystroke, remove the call to InvokeHtmlKeyPress from within the
block, and insert it after.
I've modified the download to do this now.
You can get MouseDown using a similar technique. In fact, in debug mode you'll see the MouseDown events written to the Debug window, from the same PreHandleEvent method. However I've not put in the plumbing to invoke an event; you could add this. You'll also find that UpdateUI fires on MouseDown. Again, this only works in Design mode.
I've used an EditDesigner to get these events. The EditDesigner is powerful, but another reason to use it is to get around a bug/problem whereby the control stops responding to keystrokes when you hook up events to the HTMLDocument. The techniques I've used workaround this bug.