DesktopHTMLViewer disables the KeyDown event

Using Windows 11 and Xojo 2022R3.2:

I create a simple-sample app with only one window. I put a KeyDown event on it. It works.

I place a WebViewer into this window. KeyDown does not fire. Even not a KeyDown in the Webviewer. Looks like the WebViewer grabs all keyboard events if it is in use?

Tried an input field, same result. Too simple to be worth a sample app. On the Mac it works. Did I miss anything? Any workarounds which work on Mac and Windows? I did not really want to use the Keyboard.Async stuff… :crazy_face: Thank you all :slight_smile:

1 Like

Are you trying to get KeyDown from the HTMLViewer ?

The only way to do that is probably to use JavaScript.

That is what I would expect.

OK, so far so good. I hate to ask “why-questions”, but here: Why is it possible to create a KeyDown event then? And by the way: Why couldn`t I grab the key anyhow? Even if it is given through to the HTMLViewer? I do not get it on the main window either … :face_with_spiral_eyes: … even not in a textfield.

1 Like

Looks like the window may be corrupted.

Try adding a new window, select all in the affected window, copy, and paste on the new window. Then remove the corrupted one, and rename the new one. Add the events you need to the new window.

Thanks for the tip, Michel. Did not work. Easy to reproduce. Even if the HTMLViewer is not active - the Keypress event is blocked always and completely. :person_shrugging:

Not a fix, but a couple of queries …
AllowTabStop property… try setting that to false?
If you have added a KeyDown event, return false and try getting the keydown from the parent.

Let me understand. If you don’t add the DesktopHTMLViewer, the window keypress fires ?
Adding DesktopHTMLViewer to the window suppressed Keypress on the window itself ?

I confirm DesktopHtemlViewer suppresses Keydown in the window.

You want to report that bug.

I know you don’t like keyboard.Async, but that seems to be the only solution yet.

An HTLViewer is a separate execution context that handles which cn handle these events. I am fairly sure you don’t get MouseDown etc either. As has already been mentioned, you will probaby have to add some javascript to your Viewer to pass these events (assuming your Viewer doesm’t want them) over to the Xojo side and do whatever threr.

Does not help. Thanks.

Yes, I know. But the “envelope” is my Window, isn’t it? That should do it.

No. Useless. Thanks again for confirming my problem - at least I am not alone :sweat_smile:

btw: Its working very well on the Mac.

Useless ? ? ? Reporting bugs is never futile. Granted, it may take a while, but that is the only sensible way to make sure Xojo takes notice.

I had a similar problem with a PopMenue included in a Container. The behavior on Mac an Win seemed to be different. On Win the PopMenue seems to lose the Focus even if it is selected via mouse before.
I introduced therefore a Timer:
#If TargetWindows Then
PopupMenu_1.SetFocus
#Else
’
#EndIf
Then the KeyDown Event Handler in the container worked for me as expected for Win and Mac.
Maybe this can help you to ?!

Sorry, up to now not one of the more serious problems I reported was solved. Maximum frustration and desperation up to thoughts to change my development environment. I think they are not interested in problems caused by Windows OS.

YES!! That helps. I set the Setfocus on the Window with 50ms Timer - and it works. Nice idea, Thank you!
:+1: