Nstableview Inside Nspopover Looks Different as Standalone

How can I pin an NSPopover to a selected NSTableCellView in swift5

From the documentation of NSTableView.doubleAction:

The clickedRow and clickedColumn properties allow you to determine which row and column the double-click occurred in or if, rather than in a row, the double-click occurred in a column heading.

@objc func tableViewDoubleAction(sender: NSTableView) {
let row = sender.clickedRow

From the documentation of clickedRow:

The index of the row the user clicked to trigger an action message. Returns –1 if the user clicked in an area of the table view not occupied by table rows.

    if row >= 0 {

NSTableView has a method rect(ofRow:):

Returns the rectangle containing the row at the specified index.

        let rowRect = sender.rect(ofRow: row)

Use this rect to position the popover

        popover.show(relativeTo: rowRect, of: sender, preferredEdge: NSRectEdge.maxY)

Put it all together:

@objc func tableViewDoubleAction(sender: NSTableView) {
let row = sender.clickedRow
if row >= 0 {
// create the popover
let rowRect = sender.rect(ofRow: row)
popover.show(relativeTo: rowRect, of: sender, preferredEdge: NSRectEdge.maxY)
}
}

NSPopover padding content on one side

Proplem solved, but I still don't exactly know why it required solving. The NSPopovers content view (or at least mine) requires an origin point of X: 13, Y: 13. For some reason, only one of my views was getting this value.

To solve this, I subclassed NSView and overrode the setFrame method forcing its x and y to always be 13, 13

-(void)setFrame:(NSRect)frameRect {
[super setFrame:NSMakeRect(13, 13, frameRect.size.width, frameRect.size.height)];
}

NSScrollView/NSCollectionView on NSVisualEffectView cause flickering

Ok, seems disabling the "Autoresize Subviews" on the problematic view will do the trick.

Load WebView URL inside Notification Bar NSPopover

You have created the Outlet in IB for the UIWebView in your Custom View ? and strung it together?



Related Topics



Leave a reply



Submit