0

Below is my code for my NSTableview cell

class MyTableCellView: NSTableCellView {
    
    var aTextField: NSTextField?

    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        aTextField = NSTextField(frame: frameRect)
        aTextField?.drawsBackground = false
        aTextField?.isBordered = false
        self.addSubview(aTextField!)
    }
   
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

How can I enable copy and paste to this cell programatically?

MacDeveloper
  • 1,334
  • 3
  • 16
  • 49
  • `NSTextField` supports copy and paste out of the box. Is `aTextField` editable? – Willeke Jul 26 '22 at 09:01
  • Yes aTextField is editable. NSTextFiled doesn't support copy and paste out of box – MacDeveloper Jul 26 '22 at 09:04
  • Probably something like [this](https://stackoverflow.com/questions/2487844/simple-way-to-show-the-copy-popup-on-uitableviewcells-like-the-address-book-ap) would help? – Tj3n Jul 26 '22 at 09:18
  • Do you want to select the text in the text field and copy/paste or do you want to select the row and copy/paste? – Willeke Jul 26 '22 at 09:19
  • I want to copy paste the text from outside and also within the rows – MacDeveloper Jul 26 '22 at 12:18
  • I'm sorry, but I don't understand what you're trying to accomplish. What do you want to copy from where or when? – Willeke Jul 26 '22 at 14:33
  • I want to copy a text from notes or google and paste it inside my tableviewcell row. I can edit my cell but I want a shortcut where I should be able to paste data. – MacDeveloper Jul 26 '22 at 16:53
  • So the cell isn't focused and first responder? Which object has focus? – Willeke Jul 26 '22 at 20:50

0 Answers0