我目前已经实现了 Table
带有 TableEditor
支持键盘支持的单元格级编辑(使用编辑器遍历单元格)。
我还需要一种删除行的方法,并且我不想采用在表旁边添加删除按钮的做法,因为它需要单击 2 次才能删除行(1 次选择行,1 次删除它) )。相反,我想要一个单独的列,其中填充了删除图标。我想到了两种方法来完成此任务,但都遇到了问题:
-
向 Table
添加另一列,使用 TableItem.setImage()
。这种方法存在多个问题,您可以在下面看到它们:
- 选择一行时,图标也会被选中
- 将鼠标悬停在图标上时,它会显示图像的工具提示,该提示显然无法禁用
- 似乎无法将图像在单元格内垂直居中
-
添加 ScrolledComposite
在表格旁边,并用删除图标填充它。这听起来有点疯狂,但实际上我已经在这个方面取得了很大的进展。这个想法是用删除图标填充 ScrolledComposite
,强制它随表格的滚动条滚动,并在单击图标时删除相应的行。我用这种方法只遇到了一个阻塞问题:
所以我的问题是:
- 如何解决这两种方法中提到的问题?
- 还有其他更好的方法吗?
I've currently implemented a Table
with a TableEditor
in my Eclipse plugin to support cell-level editing with keyboard support (to traverse cells with the editor).
I also need a way to delete rows, and I didn't want to go with the practice of adding a delete button next to the table as it requires 2 clicks to delete a row (1 to select a row, and 1 to delete it). Instead I want a separate column which is populated with delete icons. I've thought of 2 ways to accomplish this and have run into issues with both:
-
Add another column to the Table
, set the icon with TableItem.setImage()
. There are multiple issues with this approach, and you can see them below:
- When selecting a row, the icon gets selected too
- When hovering over the icon, it gets a tooltip of the image which apparently can't be disabled
- Can't seem to vertically center the image inside the cell
-
Add a ScrolledComposite
next to the table and fill it with delete icons. This sounds a little insane, but I've actually made it pretty far with this one. The idea is to fill a ScrolledComposite
with delete icons, force it to scroll with the table's scrollbar, and delete the corresponding row when an icon is clicked. I've only run into one blocking issue with this approach:
- Can't seem to hide the scrollbar
So my questions are:
- How I can solve the issues mentioned for either of these approaches?
- Is there some other better approach?
发布评论
评论(1)
我找到了一种隐藏第二种方法的滚动条的方法。基本上您需要做的就是:
然后将
ScrolledComposite
的宽度设置为1
以消除不可见的ScrollBar
占用的额外空间向上。并保持滚动条同步:
结果:
I found a way to hide the scrollbar for my 2nd approach. Basically all you need to do is:
And then set the width of the
ScrolledComposite
to1
to get rid of the extra space the invisibleScrollBar
takes up.And to keep the scrollbars in sync:
The result: