如何查看 NSTextFieldCell 中的整个字符串?

发布于 2024-12-29 18:13:06 字数 188 浏览 4 评论 0原文

当我在 NSTableView 中放入长字符串时,文本不会完全显示:

The string is too long

我需要允许用户可以查看整个字符串(也许可以使用滚动或工具提示,这并不重要)。有什么建议吗?

谢谢

When I put a long string inside my NSTableView the text isn't displayed wholly:

The string is too long

I need to allow user to see the whole string (maybe with scroll or tooltip, it doesn't matter). Any suggestions?

Thanks

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

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

发布评论

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

评论(1

救星 2025-01-05 18:13:06

如果可以使用多行文本视图,这将是最简单的解决方案。
但从你的例子来看,我猜答案是否定的。

您可以将 NSTextField 嵌入滚动视图中。
如果文本长于允许的宽度,您可以简单地显示滚动手柄。
如果没有,它们将不会显示,用户甚至看不到它是滚动视图。

对于上面的两个例子,了解文本的实际长度以及是否
文本字段足够长以显示整个文本。

您可以执行 [textField sizeToFit][textField frame].size.width 进行检查。

If it is ok to have a multiline text view, this would be the easiest solution.
But from your example I guess the answer is no.

You could embed the NSTextField in a scroll view.
If the text is longer than the allowed width, you could simply show the scroll handles.
If not, they would not be shown and the user doesn't even see that it's a scroll view.

For both of the above examples, it will be helpful to know how long the text actually is and if
the textfield is long enough to display the whole text.

You can do [textField sizeToFit] and [textField frame].size.width to check.

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