roadlabs / cefpython

Automatically exported from code.google.com/p/cefpython
0 stars 0 forks source link

The popup window and parent window can't script each other in the wxpython.py example #171

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The keyboard problems in popup windows in wxPython (Issue 80) were fixed by 
implementing LifespanHandler.OnBeforePopup. The creation of popup window by CEF 
is cancelled and popup browser is created on our own. The implication of this 
is that the popup window and parent window can't script each other. The 
"window.opener" is not available in the popup browser.

I think we might be able to fix this by modifying the OnBeforePopup 
implementation to this:

1. Create wx.Frame, but do not embed browser in it
2. Use the windowInfo argument to call windowInfo.SetAsChild with the wx.Frame 
handle

This way we take care of creating the window itself, by leave teh embedding of 
the browser to CEF. I think this could fix the popup<>parent scripting issues.

However, OnBeforePopup runs on the IO thread and wx.Frame window creation must 
run on the UI thread. So it must wait in the OnBeforePopup until the window is 
created. How can to accomplish that? How to pause the execution on the IO 
thread and return window handle back from the the UI thread to the IO thread?

Original issue reported on code.google.com by czarek.t...@gmail.com on 23 Jan 2015 at 11:41

GoogleCodeExporter commented 8 years ago
Created topic on the CEF Forum for this issue: 
http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=12596

Original comment by czarek.t...@gmail.com on 23 Jan 2015 at 7:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
There is a solution for this issue, Marshall provided the idea:

  Create a hidden window when your application starts. Parent the new popup browser to
  the hidden window in OnBeforePopup. After the browser exists (OnAfterCreated) create
  the desired target window and re-parent the browser to that target window.

I think this should be implemented only in wxadvanced.py and in cefpython3.wx, 
as it complicates things a bit. In wxsimple.py just provide a comment about 
keyboard issues in popups and the fix.

Original comment by czarek.t...@gmail.com on 23 Jan 2015 at 7:56