Page 2 of 2

Re: CEFBrowser don't resize properly if container NSView res

PostPosted: Fri May 21, 2021 11:19 am
by stallent
Finally figured this out, btw. Figured i'd post up for posterity.

Much like others, I'm using a CEF view that is hosted in a StackView inside an NSSPlitView. When doing this, its common for AutoLayout to set your view to a size that isn't whole numbers. Seems that when the frame's .height isn't whole, CEF internally scrolls the web content when it shouldn't.

My fix was to basically have a wrapper view with a single child (with no layout constraints or autoresizing mask). The child (targetView in my example) is what i hand to CEF to draw into and then do this in the wrapper view's layout:

Code: Select all
override func layout() {

  self.targetView.frame = self.bounds.integral

The key being the .integral. This ensures the view CEF is interacting with never has fractional size and no longer scrolls into oblivion.

Hope this helps.