Moving CEF view from one content window to another (Mac)

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Moving CEF view from one content window to another (Mac)

Postby francoismarchal » Fri Sep 23, 2016 4:40 am

Dear all,

I'm using CEF views in an application that allows the user to drag a browser view from one window to another. So I need to detach the NSView created by CEF from the content view of one NSWindow and attach it to another content view. It works well on Windows, I can set the parent to the CEF browser host HWND to the window of my choice.

The problem I have on Mac is that when I try to remove CEF browser host NSView from its parent view, CEF detects that the view is no longer attached to a window and it disposes the browser is closed. When I attach the view on my new window, there is no content.

This appends when I execute

Code: Select all
[myCEFHostView removeFromSuperView];


If I try to avoid to remove the view first from its superview, and add it to the new view directly, it crashes

Code: Select all
[myNewContentView addSubview: myCefHostView]


Any clue ? How does Chromium Mac handles moving one tab from one window to another ?

Thanks for your help!

- François
francoismarchal
Newbie
 
Posts: 5
Joined: Fri Sep 23, 2016 4:26 am

Re: Moving CEF view from one content window to another (Mac)

Postby magreenblatt » Mon Sep 26, 2016 10:19 am

We perform similar logic in cefclient: https://bitbucket.org/chromiumembedded/ ... _mac.mm-47

Check that you're not releasing references to the NSView before the reparenting process is complete.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Moving CEF view from one content window to another (Mac)

Postby francoismarchal » Tue Sep 27, 2016 5:06 am

Thanks a lot it works now, that was my mistake!
francoismarchal
Newbie
 
Posts: 5
Joined: Fri Sep 23, 2016 4:26 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 89 guests