OSX with CEF3 and OnFileDialog

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.

OSX with CEF3 and OnFileDialog

Postby schetle » Wed Jul 30, 2014 9:49 pm

I'm implementing the CefDialogHandler, and have a custom OnFileDialog.

My only question is - why is the browser object passed to OnFileDialog NULL? I need the browser object to get the window handle to properly display an NSOpenPanel in the proper window, but can't access the browser object.

I'm doing nothing out of the ordinary that I know of.

Thanks!

Code: Select all

/* MyHandler.h */

class MyHandler : public CefDialogHandler
...

virtual CefRefPtr<CefDialogHandler> GetDialogHandler() OVERRIDE {
return this;
}

virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
                          FileDialogMode mode,
                          const CefString& title,
                          const CefString& default_file_name,
                          const std::vector<CefString>& accept_types,
                          CefRefPtr<CefFileDialogCallback> callback) OVERRIDE;


Code: Select all

/* MyHandler.mm */

bool MyHandler::OnFileDialog(CefRefPtr<CefBrowser> browser,
                          FileDialogMode mode,
                          const CefString& title,
                          const CefString& default_file_name,
                          const std::vector<CefString>& accept_types,
                                        CefRefPtr<CefFileDialogCallback> callback) {
   
   
    /*

        NSWindow *browserWindow = [browser.get()->GetHost()->GetWindowHandle() window]; // EXC_BAD_ACCESS, browser ptr_ = NULL

        NSWindow *browserWindow = [browser->GetHost()->GetWindowHandle() window]; // EXC_BAD_ACCESS, browser ptr_ = NULL

    */


    ...
schetle
Techie
 
Posts: 14
Joined: Sat Mar 08, 2014 4:54 am

Re: OSX with CEF3 and OnFileDialog

Postby fernandomorgan » Thu Jul 31, 2014 5:33 pm

You can implement

FileDlg(std::vector<CefString>& file_paths, FileDialogMode mode, const CefString& title, const CefString& default_file_name, const std::vector<CefString>& accept_types)

and then call the native NSOpenPanel, etc,
fernandomorgan
Techie
 
Posts: 28
Joined: Tue Jan 14, 2014 5:51 pm

Re: OSX with CEF3 and OnFileDialog

Postby schetle » Thu Jul 31, 2014 8:33 pm

Is that something I need to override from Chromium? I don't see a reference to that anywhere in the CEF3 code.

Is there a reason why the browser object is null that I'm missing?

I wouldn't bother with the native NSOpenPanel, if the default File Dialog wouldn't spinning-wheel crash the app when the file dialog is canceled while AppStore sandboxing is turned on. Instruments shows that it's endlessly trying to access things it shouldn't, when cancelled. But that's a different question for a different thread.
schetle
Techie
 
Posts: 14
Joined: Sat Mar 08, 2014 4:54 am

Re: OSX with CEF3 and OnFileDialog

Postby magreenblatt » Tue Aug 05, 2014 5:04 am

schetle wrote:why is the browser object passed to OnFileDialog NULL?

How are you triggering the file dialog?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: OSX with CEF3 and OnFileDialog

Postby schetle » Tue Aug 19, 2014 12:02 am

The file dialog was being triggered by any file input from standard websites.
schetle
Techie
 
Posts: 14
Joined: Sat Mar 08, 2014 4:54 am


Return to Support Forum

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 43 guests