如何为 StyledText 组件启用自动滚动
我正在使用 StyledText
组件,其行为有点类似于流行的 eclipse IDE 控制台视图(附加日志),但在这里,在我的 StyledText
组件中,滚动锁已启用。我的意思是,对于附加到 StyledText 的每一行,垂直滚动条位置保持不变。下图反映了行为:
作为尝试,我尝试了这样的操作:
StyledText
声明
StyledText styledText = new StyledText(parent, SWT.V_SCROLL);
//other relevant code here
styledText.addListener(SWT.SCROLL_LOCK, new Listener() {
@Override
public void handleEvent(Event event) {
// TODO Auto-generated method stub
event.doit=false;// i tried true also doesn't work
}
}) ;
如何禁用(滚动锁定)?显示附加的最后一行以及底部的滚动(垂直)栏位置?
I'm using StyledText
component which behaves somewhat similar to the popular eclipse IDE console view, (which appends the log), but here, in my StyledText
component the scroll-lock is enabled. I mean for each line appended to the StyledText
, the vertical scroll bar position remains constant. Below image reflects the behavior:
As an attempt I tried like this:
StyledText
declaration
StyledText styledText = new StyledText(parent, SWT.V_SCROLL);
//other relevant code here
styledText.addListener(SWT.SCROLL_LOCK, new Listener() {
@Override
public void handleEvent(Event event) {
// TODO Auto-generated method stub
event.doit=false;// i tried true also doesn't work
}
}) ;
How do I disable (scroll lock)? show the last line appended and with the scroll(vertical) bar position at the bottom?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果插入符号在附加之前位于文本末尾,我会尝试在附加后将插入符号设置在文本末尾。这将允许用户通过在其他位置设置插入符号来停止自动滚动,并通过在末尾设置插入符号来重新启用自动滚动。
I'd try to set the caret at the end of the text after appending if it was at the end of the text before appending. This would allow the user to stop autoscrolling by setting the caret somewhere else and to re-enable autoscrolling by setting the caret at the end.
这似乎对我来说非常有效。可以添加一堆文字,向下滚动。添加更多文本,上下滚动结束数据量:
我所做的就是将 SWT.H_SCROLL、SWT.H_VSCROLL 和 SWT.BORDER 添加到 styledText,并将其放入父级 ScrolledComposite 中:(祝你好运! )
This seemed to work perfectly for me. Can add a bunch of text, scroll down. Add more text, scroll up and down ending amount of data:
All I do is add the SWT.H_SCROLL,SWT.H_VSCROLL and SWT.BORDER to the styledText, which I dropped into the parent, ScrolledComposite: (best of luck to you!)