格式化字符

发布于 2024-09-13 21:44:12 字数 192 浏览 13 评论 0原文

我有一个应用程序(IM 客户端),我希望以类似于 mIRC 的方式设置自定义格式符号,而不是依赖于富文本。我将通过将 UniChar 003 与数字 0-15 配对来处理不同事物的颜色和其他字符来实现此目的。我遇到的唯一问题是,当插入这些字符时,它们是不可见的,因此最终用户很难在需要时删除它们。有没有办法以显示特定不可见字符的方块的方式操作 NSTextField ?

I have an application (IM Client) that I wish to setup custom formatting symbols in similar to mIRC rather than relying on rich text. I will accomplish this by pairing a UniChar 003 with a number 0-15 to process colors and other characters for different things. The only problem that I have is that when these characters are inserted they are invisible so it is difficult for the end user to thus delete them when needed. Is there a way to manipulate NSTextField in a way to show squares for specific invisible characters?

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

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

发布评论

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

评论(1

儭儭莪哋寶赑 2024-09-20 21:44:12

您可以将它们替换为文本字段中的可见字符,并且当用户完成时将它们替换回来:

NSString *visibleFormatCharacters=[stringWithInvisibleCharacters stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%c",0x03] withString:@"§"]];

当用户完成时向后执行:

NSString *invisibleFormatCharacters=[visibleFormatCharacters stringByReplacingOccurrencesOfString:@"§"] withString:[NSString stringWithFormat:@"%c",0x03]];

You could replace them whith a visible character in the Text field, and when the user is done replace them back:

NSString *visibleFormatCharacters=[stringWithInvisibleCharacters stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%c",0x03] withString:@"§"]];

when the user is done do it backwards:

NSString *invisibleFormatCharacters=[visibleFormatCharacters stringByReplacingOccurrencesOfString:@"§"] withString:[NSString stringWithFormat:@"%c",0x03]];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文