Search code examples
objective-cswiftnstableviewnstextfieldnstablecellview

NSTextfield renaming implementation on custom button in NSTableView


I have NSTableView and a button in NSTableViewCell. I want to implement the functionality when the user clicks on my NSButton and cell goes to the renaming mode of its NSTextField.

I already set up action outlet for button and know when it's clicked but can't really find any info on how to trigger renaming. The answer might be pretty easy but I can't get to it. Thank you in advance!

P.S. I use Swift but any help would be great


Solution

  • Well, the answer is actually very easy, it's the lack of related information that makes it kinda hard. So, in case anybody's looking for the same thing, that's how I implemented this feature(it's actually one-liner):

    in your action outlet just call

    cell.textField?.selectText(self)
    

    and the text's gonna get selected. After that just keep implementing it as usual.