A customer reported a bug a couple of days ago, that in Help Builder pressing F5 in the visual topic editor caused the topic to be completely erased. This actually makes sense since Help Builder users the Ie Web Browser Control in Edit Mode to handle the WYSIWYG interface display. Pressing F5 in Internet Explorer of course causes a Refresh and in this case the control is refreshing a temporary file that is no longer there – hence the empty document.

 

Help Builder already intercepts a bunch of keystrokes to pop up its own dialogs for image insertion, table editing, hyperlinks and crosslink insertion etc. all of which are driven through hotkeys in the Help Builder UI. But all of those hotkeys usually have no effect on the editing UI since they tend to be non-typed characters.

 

With this F5 situation though, I need to completely throw out the key stroke. My initial intuition would be:

 

   PROCEDURE HTMLTextContainerEvents_onkeydown() AS VOID

   LOCAL loEvent, loBrowser

  

   loEvent = this.oDoc.ParentWindow.Event

 

   lnKeyCode = loEvent.KeyCode

 

   *** F5 -  Ignore: It clears the page normally!

   IF lnKeyCode = 116  

         loEvent.cancelBubble = .T.

         loEvent.returnValue = .F.

         RETURN

   ENDIF

 

but as it turns out this doesn’t work. It works with ‘standard’ keys, but F5 is apparently a hot special key and calling cancelBubble and overriding the current event isn’t enough to kill it.

 

What did work in the end was to override the keycode directly:

 

loEvent.keyCode = 0

 

OnKeyDown is the first of the key events that fires so changing the KeyCode value affects the other events firing later on and this apparently stops the F5 keys from doing its thing.

 

Hope this saves somebody some time.

 

 

On a related note: After having played with Expression Web Designer (or the SharePoint Designer in Office 2007) I’m really, really wishing that Microsoft will consider creating an HTML Editing control of some sort based on that interface. Even if it requires a license of either of these tools, but damn it there need to be some better tools for HTML editing out there for desktop applications. It’s funny that there are actually better Web controls available for editing than desktop controls, but even those do horribly when it comes to embedding code for example. The hoops I had to jump through to get Help Builder to allow decent code editing is messy as hell.

 

The IE editing is a lousy editing environment in general and this is one area where third parties have not really stepped in to provide better solutions. There are a few alternatives that don’t use Internet Explorer for editing, but unfortunately their rendering quality is not quite good enough for true WYSIWYG interfaces.

 

So here’s to hoping that somebody – Microsoft or otherwise will consider building a decent editor control that can be embedded into desktop applications. I don’t know about you, but just about all of my desktop applications have the need to edit HTML in one way or another. Heck just think of all the BLOG editors out there and the crummy HTML editing experience they provide overall. Even Office (Outlook) does a bad job of it (athough better in Office 2007).

 

I’m not holding my breath but I can hope can’t I? <g>