HTMLViewer Control Blocking Backspace Key

Hi Everyone,

I’m building an application which uses a HTMLViewer control to display system type messages. The HTMLViewer doesn’t require any user interaction so it’s enabled property is set to false. I’m not trapping any key board events on the control as I want all key board events to be handled by the parent window. All sounds simple right? However when the HTMLViewer is visible all keyboard events pass through except the backspace key.

It’s easy to replicate. Create a desktop application. Drop the following code into the keydown event of the window, so the title is updated with the key code. Without the HTMLViewer visible the title of the window should change to “8” when the back space key is pressed. With the HTMLViewer visible the backspace key no longer works.

title = Cstr(ASC(key)) return true

I would love to know if someone has a solution to this as I’ve had to start using a TextArea control and working with the Styled text can be slower.

I’ve only tried this on a Mac so I don’t know if the same happens on other platforms.

I’m using XOJO 2014 R1 but I’ve tested in previous versions and the same happens.

Hope someone has an answer.

Regards

Trig

Any control will get the focus. To put the focus back to the window, enter ClearFocus in the Open event of the HTMLViewer. Use the same to put back focus to the window whenever necessary.

Thanks Michel,

That’s pointed me in the right direction. Strangely the ClearFocus doesn’t work for me in the HTMLViewer Open Event, nor the Window Open Event when the application is first run. If I call a ClearFocus after the Window is fully displayed then it works. I only have a HTMLViewer and Canvas on the form so it might be that the HTMLViewer is getting focus by default.

The bit that is confusing me is that if a control is not enabled then it should not get focus anyway.

Regards

Trig

[quote=73217:@Trig Charters]Hi Everyone,

I’m building an application which uses a HTMLViewer control to display system type messages. The HTMLViewer doesn’t require any user interaction so it’s enabled property is set to false. I’m not trapping any key board events on the control as I want all key board events to be handled by the parent window. All sounds simple right? However when the HTMLViewer is visible all keyboard events pass through except the backspace key.[/quote]

It’s not just the backspace key, HTMLViewer seems to have a bug related to focus with other control keys, including space. It sounds identical to FR #25955 which is unfortunately marked as fixed and isn’t visible to non-beta testers.

Hi Gavin,

It has been quite annoying… Thanks to Michel’s advise, which pointed me in the right direction, I finally have a work around, which is to set focus to another control when the application starts then give that control a LostFocus method to reapply the Focus if it is lost.

This works fine but it’s not something I should have to do.

Regards

Trig