如何为StyledText组件启用自动滚动 [英] How to enable autoscroll for a StyledText Component

查看:136
本文介绍了如何为StyledText组件启用自动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 StyledText 组件,该组件的行为与流行的Eclipse IDE控制台视图(附加了日志)有些相似,但是在这里,在我的<$ c $中c> StyledText 组件启用了滚动锁定。我的意思是对于 StyledText 后面的每一行,垂直滚动条的位置保持不变。下图反映了该行为:

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:

我尝试这样尝试:

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
            }
        }) ;

如何禁用(滚动锁定)?显示附加的最后一行,并且滚动条(垂直)的位置在底部?

How do I disable (scroll lock)? show the last line appended and with the scroll(vertical) bar position at the bottom?

推荐答案

我将尝试设置如果在插入之前在文本末尾,则插入符在文本末尾。这样一来,用户可以通过在其他地方设置插入符号来停止自动滚动,并通过在最后设置插入符号来重新启用自动滚动。

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.

这篇关于如何为StyledText组件启用自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆