如何防止 Flex UITextField 中单词和标点符号之间出现换行?
我正在 Flex 3.x UITextField 中渲染 html。我现在面临的问题是,当标点符号位于单词末尾时,有时可以换行到下一行。
例如:
杀不死我的,都会让我变得更坚强
,所以我成为了一名开发人员。
对我来说,这似乎是算法中的一个错误。有解决方法吗?
I am rendering html in a Flex 3.x UITextField. The problem I am facing now is that when punctuation is at the end of a word, it can sometimes be wrapped to the next line.
For example:
That which doesn't kill me makes me stronger
,so I became a developer.
This seems like a bug in the algorithm to me. Is there a workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一直在尝试重现您的问题,但就我而言,当我调整窗口大小时,该字段中的文本会被切断,它不会换行。
无论如何,您是否尝试过在文本中使用
\n
换行符来强制换行符出现在您想要的位置,或者您的文本是否需要随窗口大小流动?I've been trying to reproduce your problem, but in my case, the text in the field just gets cut off when I resize my window, it doesn't wrap.
In any case, have you tried a
\n
new line character with the text to force the line break to occur where you want it to, or does your text need to flow with the window size?@Wade 该组件并不是真正设计用于调整大小的,尽管它确实在调整大小时进行了包装。您是否将自动换行设置为true?
@Armagosh 我无法提前知道换行符会在哪里发生。它取决于屏幕分辨率和自动换行的 Flex 算法。我也不清楚这是否有帮助。如果我在逗号后面放两个空格,是否会阻止逗号出现在换行符后面?
它呈现许多不同的 xhtml 项目中的任何一个,其中一些项目在某些分辨率下最终会在行尾出现“,”。连字符也会出现同样的问题。
附录:所以本质上,是的,我需要包装随着窗口大小而流动。
@Wade This component isn't really designed to be resized, though it does wrap on resize. Did you set the wordwrap to true?
@Armagosh I can't know where the line breaks will occur ahead of time. It depends on screen resolution and the Flex algorithm for wordwrapping. I am also not clear if this will help. If I put two spaces after the comma, would that prevent the comma from being after the line break?
It renders any one of a number of different xhtml items, some of which will wind up having the ',' be at exactly the end of the line in some resolutions. The same problem happens with hyphens.
Addendum: So essentially, yes, I need the wrapping to flow with window size.