gpt4 book ai didi

macos - 在 NSTextField 上按下 Enter 键时如何做某事

转载 作者:搜寻专家 更新时间:2023-11-01 05:45:44 24 4
gpt4 key购买 nike

我正在使用 Swift 为 Mac 编写应用程序。

我在 NSTextField 对象中写了一个字符串,我想将它保存在一个 .txt 文件中。我希望在用户按下 Enter 键后立即发生这种情况。我的方法 .writeToFile() 已准备就绪,我不知道如何让它在按下该键后立即运行。

我找不到 Swift 语言的正确答案。谢谢。

最佳答案

@IBAction func textFieldAction(sender: NSTextField) {
print(sender.stringValue)
}

connections inspector

attributes inspector

关于macos - 在 NSTextField 上按下 Enter 键时如何做某事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27049783/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com