lvsti / CEF.swift

Swift bindings for the Chromium Embedded Framework
BSD 3-Clause "New" or "Revised" License
94 stars 29 forks source link

onBeforeClose not called? #22

Closed infrom-software closed 6 years ago

infrom-software commented 6 years ago

I don't manage to have CEFLifeSpanHandler.onBeforeClose(browser: CEFBrowser) triggered after windowShouldClose(_ sender: NSWindow) returns true and the window is destroyed. (browser's view being child of a view in the window of the app in my test sample, i.e. the window is not created by CEF)

lvsti commented 6 years ago

from the header comments of DoClose:

Called when a browser has recieved a request to close. This may result directly from a call to CefBrowserHost::CloseBrowser() or indirectly if the browser is parented to a top-level window created by CEF and the user attempts to close that window (by clicking the 'X', for example).

To me this means that if you want to receive onDoClose you either have to have the browser in a CEF-managed window or call CEFBrowserHost.closeBrowser() manually

infrom-software commented 6 years ago

My fault. onBeforeClose won't be triggered if client.browser.host.windowHandle.removeFromSuperview() is not called (from inside windowShouldClose), even if .allowed by onDoClose (after a closeBrowser(), yes).