可以将HTML样式链接添加到SWT StyledText吗? [英] Can HTML-Style Links be added to SWT StyledText?
问题描述
我知道SWT有一个Link类来创建HTML一个href样式链接作为小部件,但我试图找到一种方法来使StyledText控件中的某些文本出现并作为一个链接。
我觉得Eclipse会在代码编辑器中执行此操作,如果您按住控件并将鼠标悬停在方法名称上,但我知道Eclipse java编辑器比StyledText控件。
自JFace 3.5以来,链接有一种特殊的风格:
styleRange.underlineStyle = SWT.UNDERLINE_LINK;
styleRange.data =http://www.google.com/;
这使得识别链接变得更加简单,您可以将URL存储在样式中。至于自动查找链接,只需在您获得的行中查找模式 http:// [^]
(链接中不允许空白)并添加样式。 / p>
I know SWT has a Link class to create HTML a href style links as widgets, but I wast trying to find a way to make certain text in a StyledText control appear and function as a link.
I feel like Eclipse does this in their code editor if you hold down control and hover over a method name, but I know the Eclipse java editor is much more complicated than a StyledText control.
Since JFace 3.5, there is a special style for links:
styleRange.underlineStyle = SWT.UNDERLINE_LINK;
styleRange.data = "http://www.google.com/";
This makes it much more simple to identify a link and you can store the URL in the style. As for automatically finding links, just look for the pattern http://[^ ]
(blanks are not allowed in links) in the lines you get and add the style.
这篇关于可以将HTML样式链接添加到SWT StyledText吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!