Page 1 of 1

How to prevent delphi WVBrowser from stealing focus

Posted: Fri Nov 11, 2022 5:50 pm
by SpringerRider
I have just completed converting an app from TWebBrowser to TwvBrowser.
It works like a charm. Thank you very much for this.

With TWebBrowser, I had the "lost focus' issue that I could never resolve. Stack Overflow has many posts pertaining to this issue but no resolution.

I had hoped that TwvBrowser would have resolved this.
QtrMinutes.jpg
To repeat, load a page. On the right side upper grid, I have a pop up menu. When I open it and select an option, then go back in the browser, the I cannot place focus on the grid.
The work-around is to click on the lower grid to get focus back.

I had hoped that the TWVWindowParent might have some way corrected this. Any ideas?

Re: How to prevent delphi WVBrowser from stealing focus

Posted: Sat Nov 12, 2022 11:17 am
by salvadordf
Hi,

TWVWindowParent overrides the SetFocus procedure to focus the browser automatically. Perhaps this is the cause of this issue.

Check if TWVWindowParent is the first control to get the focus in the form. Perhaps you can fix this by changing the TWVWindowParent.TabStop property and setting TabStop := 0 in a different control.

Try setting the grid as focused automatically after executing each menu option.

There are several TWVBrowser functions and events related to the browser focus that might be useful too.