如何像“To/CC”中那样自定义 NSTokenField mac 邮件中的字段?

发布于 2024-08-22 17:38:09 字数 230 浏览 7 评论 0原文

我能够使用 NSTokenField,它很容易使用..但我希望您建议我如何自定义它,就像在 mac mail ie 中的“收件人/抄送”字段中一样。当没有。令牌字段中的令牌数量增加,“To”字段的高度增加到一定限制,然后开始出现垂直滚动条!

默认情况下,当我们使用令牌字段时,其高度不会增加,也不会出现垂直滚动条!我在 IB 中尝试了不同的组合,但无法获得类似 mac 邮件的功能。

有人能给我建议一些解决方案吗?

I am able to work with NSTokenField, it is easy to use.. but I want your suggestions on how can I customize it just like it is in "To/ CC" fields in mac mail ie. when no. of tokens in a token field increases height of "To" field gets increased to a certain limit then a vertical scroller starts appearing!

By default when we use a token field neither its height gets increased nor a vertical scroller appears! I tried different combinations in IB but I could not obtain mac mail like functionality.

Can anyone suggest me some solution for it??

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

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

发布评论

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

评论(2

小瓶盖 2024-08-29 17:38:09

您必须继承 NSTokenField 才能获得您想要的功能。请务必调用 setWraps: YES。

当令牌字段的内容发生更改时,您必须计算令牌字段所需的大小并自行调整其大小。与添加滚动条相同。令牌字段的高度达到一定大小后,您将在该字段中插入滚动视图。相反,当重新计算的令牌字段大小小于临界大小时,您将删除滚动视图。

(我发现)要使其正常工作,需要做大量的工作。苹果表示,NSTokenField“提供类似于邮件应用程序中的地址字段的标记化编辑”,但它实际上一点也不相似,因为它没有内置的大小调整功能,并且拖放对于除文本之外的任何内容都是有问题的。

You'll have to subclass NSTokenField to get the functionality you want. Be sure and call setWraps: YES.

When the contents of the token field changes, you'll have to calculate the required size of your token field and resize it yourself. Same with adding a scroll bar. After the height of the token field reaches some size, you'll insert a scroll view into the field. Conversely, when the recalculating of the token field size is less than the critical size, you'll remove the scroll view.

This is a considerable amount of work (I've found) to get it work correctly. Apple says that the NSTokenField "provides tokenized editing similar to the address field in the Mail application", but it's really not that similar at all since it doesn't have resizing built in and drag and drop is problematical for anything except text.

倾听心声的旋律 2024-08-29 17:38:09

我能够使用 IFVe​​rticallyExpandingTextField 来实现此目的。因为 NSTokenField 继承自 NSTextField,所以我使 IFVerticallyExpandingTextField 继承自 NSTokenField,然后子类化 IFVerticallExpandingTextField 以实现我需要使用我的 NSTokenField 版本执行的所有操作。

这应该只是一个简单的插入。它应该立即开始工作。

I was able to achieve this using IFVerticallyExpandingTextField. Because NSTokenField inherits from NSTextField, I made IFVerticallyExpandingTextField inherit from NSTokenField and then subclassed IFVerticallExpandingTextField to implement all the things I needed to do with my version of NSTokenField.

This should just be a drop in. Right away it should start working.

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