Page 1 of 1

OnSetFocus not working

Posted: Mon Jun 28, 2021 2:37 pm
by thefunkyjoint
Hi,

I use the onSetFocus method setting result := true when i want to avoid the browser to steal focus. It always worked well but looks like the last update broke this functionality ; the browser is stealing focus anyway.

Can anyone confirm this please ?

Thanks

Re: OnSetFocus not working

Posted: Mon Jun 28, 2021 8:52 pm
by salvadordf
Hi,

I just did some tests with the TabbedBrowser2 demo.

I added a small TEdit in the left panel and I used the OnKeyUp to create a new tab when I press the "a" key.

The unmodified TabbedBrowser2 demo set the focus on the new browser tab but then I did a couple of modifications :
  • Use the TChromium.OnSetFocus event and set Result to true
  • Set TChromium.DefaultWindowInfoExStyle to WS_EX_NOACTIVATE before the TChromium.CreateBrowser call.
With those modifications the TEdit kept the focus when I pressed "a" even after creating the new browser tab.

Re: OnSetFocus not working

Posted: Tue Jun 29, 2021 9:19 am
by Student
To prevent the browser from stealing focus, I usually set the enabled = false property of TchromiumWindow, when I know for sure that this browser is not used, and when the tab is activated, then enabled = true

Re: OnSetFocus not working

Posted: Tue Jun 29, 2021 12:15 pm
by thefunkyjoint
I'll do some tests with these suggestions.

What i noticed is, when my application is idle but with some web page open (Instagram for instance), randomly the app will popup in front of other windows, probably because a new notification has arrived on Instagram, for instance. This behaviour did not happen prior to recent updates.