Removing Border from NSBrowser

609 views Asked by At

As the title says, I actually want to remove the border from an NSBrowser control. The parents are NSView and NSControl. There's no available methods in NSBrowser itself, and neither in the parent controls. This one seems completely undocumented.

As to the reason for removing the border, because it's programatically docked into another view, so the view hierarchy means there's a border already.

Any ideas?

5

There are 5 answers

2
uchuugaka On

NSBrowser uses NSBrowserCell to implement its interface. That inherits from NSCell. NSCell should provide the methods you need.

From NSCell class reference... Managing Display Attributes – setBezeled: – isBezeled – setBordered: – isBordered – isOpaque – setControlTint: – controlTint – setBackgroundStyle: – backgroundStyle – interiorBackgroundStyle

1
processed-bits On

Neither of existing answers worked for me.

  • Embedding in NSView looked like an acceptable workaround, but it clips the browser.
  • NSScrollView isn't superclass of NSBrowser.
  • Layer is not used for this border, it's nil.
  • NSBrowserCell has nothing to do with NSBrowser's border.

Use borderType: NSBorderType property (same as in some other classes), setting it in Interface Builder. In Identity Inspector (++3) add to User Defined Runtime Attributes:

Key Path: borderType
Type: Number
Value: 0 (corresponds to NSBorderType.noBorder)

0
Ales Tsurko On

For those, who still looking for a solution. NSBrowser is the subclass of NSView. You can set an NSView layer's border width to 0:

(Swift)

self.layer?.borderWidth = 0
1
Ken Thomases On

Just embed it a plain NSView ("Custom View" in IB) and make the browser's frame "outset" by 1 point in all directions from the containing view's bounds. The containing view will clip the browser to eliminate the border. Then place that containing view into the surrounding view hierarchy, rather than adding the browser directly.

3
Aditya Vaidyam On

Remove the border on the NSScrollView that it is enclosed in.