NSTextField 添加取消按钮

发布于 2024-12-29 20:10:39 字数 292 浏览 4 评论 0原文

使用 iOS 和 UISearchBar,您可以在文本字段中设置一个漂亮的小取消按钮,类似于:

在此处输入图像描述

(请注意,我在另一篇文章中找到了该图像,并且“啊!”与我的情况无关)。

现在就我而言,我使用可可和 NSTextField,我想知道添加类似内容的最简单方法是什么。最糟糕的情况是,我将创建一个带有图像/按钮的自定义 NSTextField,但如果我缺少一种明显的方法来执行此操作,我宁愿不重新发明轮子。

Using iOS and a UISearchBar you can have a nice little cancel button setup within the text field similar to this:

enter image description here

(Note I found the image on another post and the 'argh!' is not relevant in my case).

Now in my case i'm using cocoa and a NSTextField and i'm wondering what the easiest way to have something similar added would be. Worse case scenario I will create a custom NSTextField with an image/button on it, but I would prefer to not reinvent the wheel if I am missing an obvious way to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帥小哥 2025-01-05 20:10:39

我不知何故忽略了 NSSearchField 组件,它基本上正是这样做的。

I somehow overlooked the NSSearchField component which does basically exactly this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文