Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

How not to set focus if we open popup

Post Reply
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How not to set focus if we open popup

Post by salvadordf »

I'm not 100% sure of what you want exactly.

Do you want to have a popup window that can't be focused?
Do you want to show the popup window in the background and keep the focus on other apps?

Anyway, in your case I would make the tests with the MiniBrowser demo because it's ready to handle popup windows created by CEF. The FMX demo is not ready and it uses the OSR mode and your app uses normal mode.

This is an alternative way to move a window to the background :
https://stackoverflow.com/questions/268 ... other-form
User avatar
danicarla2
Posts: 19
Joined: Mon Oct 01, 2018 6:01 pm
Location: Brazil

Re: How not to set focus if we open popup

Post by danicarla2 »

Hi guys.. I believe that my doubt is a little similar

My html open a popup attributing a name to it.. example:

Code: Select all

<script>
function NewWindow(page,name,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(page,name,settings);
}
</script>
<a href="test.html" onclick="NewWindow(this.href,'NameWindow','800','550','yes');return false">test</a>
But if minimize Pop-up and click on another link.. it opens the page in the open window without giving the focus..
Is there a way to assign focus that way?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How not to set focus if we open popup

Post by salvadordf »

Set the TCEFWindowParent.TabStop := TRUE and TCEFWindowParent.TabOrder := 0;
If TCEFWindowParent is a child of other Delphi components make sure they also have the same value for the TabStop property to be sure TCEFWindowParent is the first component to have the focus when your app runs.
User avatar
danicarla2
Posts: 19
Joined: Mon Oct 01, 2018 6:01 pm
Location: Brazil

Re: How not to set focus if we open popup

Post by danicarla2 »

Something like? im usin the Mini Browser demo
Image
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How not to set focus if we open popup

Post by salvadordf »

Yes. I tested what you said with a popup window in the minibrowser and, if I understood correctly, those properties fix this problem.
I also added an INPUT element with "autofocus" in the web pages to see the blinking cursor when I clicked the last link.
User avatar
danicarla2
Posts: 19
Joined: Mon Oct 01, 2018 6:01 pm
Location: Brazil

Re: How not to set focus if we open popup

Post by danicarla2 »

Strange... for me it did not work..

I tried putting the focus through HTML and it also did not work
Post Reply