How do I adjust content insets of the `browser_view`?

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.

How do I adjust content insets of the `browser_view`?

Postby noMrnnnthr » Thu Apr 02, 2020 12:28 pm

I'm new to CEF project. I was trying to convert `browser_view` to NSClipView or NSScrollView, then set `automaticallyAdjustsContentInsets` to `YES`, like this:

Code: Select all
// in root_window_mac.mm
// after
/*
if (!is_popup_) {
        // Create the browser window.
        browser_window_->CreateBrowser(
...
*/

NSScrollView* browser_view = (NSScrollView*)CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(GetWindowHandle());
[browser_view removeFromSuperview];
browser_view.automaticallyAdjustsContentInsets = YES;
[window_ setContentView:browser_view];

// followed by
/*
if (!initially_hidden) {
        // Show the window.
        Show(RootWindow::ShowNormal);
..
*/


Without `browser_view.automaticallyAdjustsContentInsets = YES;`,the window pops up fine without error.

Please help me about how to achieve this? Many thanks~
noMrnnnthr
Newbie
 
Posts: 3
Joined: Thu Apr 02, 2020 12:13 pm

Re: How do I adjust content insets of the `browser_view`?

Postby magreenblatt » Thu Apr 02, 2020 2:09 pm

The browser view is not a NSScrollView so your type cast is invalid. If you want to set the insets you need to parent the browser view to another NSView that supports that.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How do I adjust content insets of the `browser_view`?

Postby noMrnnnthr » Thu Apr 02, 2020 8:04 pm

magreenblatt wrote:The browser view is not a NSScrollView so your type cast is invalid. If you want to set the insets you need to parent the browser view to another NSView that supports that.

Thank you. How can I forget the `parent_handle`! :D
noMrnnnthr
Newbie
 
Posts: 3
Joined: Thu Apr 02, 2020 12:13 pm


Return to Support Forum

Who is online

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