SWT 表:如何设置/获得“聚焦"排 [英] SWT table: how to set/get "focused" row

查看:32
本文介绍了SWT 表:如何设置/获得“聚焦"排的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 和 Linux 上,当按住 Ctrl 键时,可以使用插入键上下移动而不更改选择.该表格显示了一些视觉反馈.

On Windows and Linux, when holding down the Ctrl key one can move up and down using the caret keys without changing the selection. The table shows some visual feedback.

我玩过一个使用 TableCursor 的 SWT 片段,但它似乎是半生不熟的,因为它引入了一些新的错误 - 例如当按下Ctrl+End时,释放Ctrl键后跳回上一个选择.

I've played with an SWT snippet which uses TableCursor but it seems half-baked, because it introduced a couple of new bugs - e.g. when pressing Ctrl+End, it jumped back to the previous selection after releasing the Ctrl key.

如何获取或设置这个焦点"行?

How to get or set this "focused" row?

推荐答案

这看起来不像是可以直接获取/设置的属性,但您可以从绘制事件中检测到焦点行并自定义绘制焦点.

This doesn't look like a property that can be get/set directly, but you can detect the focused row from paint event and custom paint the focus.

添加Listener 到您的 SWT.PaintItem 事件表:

handleEvent(PaintEvent e) {
    if (e.detail & SWT.FOSCUSED != 0)
        myFocusedRow = ((Table)e.widget).indexOf((TableItem)e.item);
    ...
    if (e.item == myFocusedItem)
        e.gc.drawFocus(e.x, e.y, e.width, e.height);
}

这篇关于SWT 表:如何设置/获得“聚焦"排的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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