0

I'm currently working on a "floating" window. The window contains a tableview with clickable rows.

var myPanel = NSPanel()

func mClipboardConfig(){
        mtPanel = NSPanel(contentRect: CGRect(x: 100, y: 100, width: 50, height: 200), styleMask: [.titled, .nonactivatingPanel], backing: .buffered, defer: true)
        mtPanel.delegate = self

        mtPanel.isFloatingPanel = true
        
        mtPanel.makeKeyAndOrderFront(self)
        mtPanel.orderFrontRegardless()
        
        let storyboard = NSStoryboard(name: "MiniCipBoardSB", bundle: nil)
        
        var controller = MiniClipboardVC()
        controller = storyboard.instantiateController(identifier: "mClipboardID") as MiniClipboardVC
   
        mtPanel.contentViewController = controller
        
       
}

enter image description here

The window "floats" above other windows as expected, but the issue is that in order to select a row I have to click on the window twice to select a row(once to "activate" the window and another to click on the row).

Is it possible to select a row in this window (with one click) while another application is in focus.

unknown
  • 788
  • 9
  • 24
  • Do you want to click when another window of the same app is active or when another app is active? – Willeke Oct 17 '21 at 09:05
  • @Willeke the questions seem to be the same. But I tried it and can't seem to get it to work. I added ``` mtPanel.becomesKeyOnlyIfNeeded = true``` to my current code. – unknown Oct 17 '21 at 12:57
  • Actually, buttons inside the panel seem to work perfectly, but the tableview row gets highlighted, but cannot be clicked ! – unknown Oct 17 '21 at 13:00
  • I'll have a try. Is it a default table view in a default Cocoa app? How does the tableview row get highlighted without a click? – Willeke Oct 19 '21 at 06:06
  • The issue was that I was using ```tableview.action``` to detect the row click (which didn't work) and now I'm using ```tableViewSelectionDidChange``` and it works. Since then I have marked the question as duplicate. – unknown Oct 19 '21 at 08:13

0 Answers0