如何更改鼠标突出显示?
在 GWT 中,我使用 CellTable。
当您将鼠标悬停在 CellTable 上时,它会突出显示每一行。
如何更改鼠标悬停时突出显示的行为?具体来说:
- 更改突出显示的颜色
- 禁用/启用
- 使其仅突出显示光标处的特定网格项目(而不是整行)< /strong>
(我当前的技巧是创建一堆 1 列宽的 CellTables 并将它们添加到 VerticalPanel 布局中...创建有一个 CellTable 的错觉,并根据您的光标突出显示每个网格。 这很糟糕吗? 性能?
In GWT, I am using CellTable.
When you mouse over the CellTable it highlights each row.
How do change the behavior of the highlighting from the mouse over? Specifically:
- change the color of highlighting
- disable/enable
- make it highlight only the specific grid item at your cursor (instead of the entire row)
( The current hack I have is to create a bunch of 1 column wide CellTables and add them to a VerticalPanel layout... creating the illusion that there is one CellTable and it highlights each grid according to your cursor. Is this bad? Why? performance? )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您会注意到 CellTable 使用 ResourceBundle,这意味着所有 css 样式都会被混淆......这使得覆盖样式变得更加困难。
CellTable 构造函数实际上允许您覆盖默认的 ResourceBundle。因此,首先,您需要创建自己的资源包,如下所示:
然后您需要创建自己的 CSS 文件。我建议将 CellTable 样式直接复制到您的项目中并使用它作为起点。您可以在这里找到它:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/cellview/client/CellTable.css
确保首先注入样式,然后将其输入到 CellTable 的构造函数中,如下所示:
具体来说,您需要调整这些样式:
值得注意的是,单元格表区分“选定行”和“键盘选择的行”。所选行是实际选择的行(即通过 SelectionModel)。键盘选择的行是指用户按下向上/向下键时突出显示的行,但并不意味着该行实际被选择(如果有意义的话)。
You will notice the CellTable uses a ResourceBundle, which means all the css styles get obfuscated ... this makes it more difficult to override styles.
The CellTable constructor will actually allow you to override the default ResourceBundle. So first, you need to create your own resource bundle like this:
Then you need to create your own CSS file. I recommend copying the CellTable style directly into your project and use that as a starting point. You can find it here:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/cellview/client/CellTable.css
Make sure the style is injected first, and then you just feed it into the CellTable's constructor like this:
Specifically, you'll want to tweak these styles:
It is important to note that the cell table differentiates between the 'selected row' and the 'keyboard selected row'. The selected row is the actual row selected (ie via SelectionModel). The keyboard selected row refers to what is highlighted when the user is pressing the up / down key, but does not mean the row is actually selected (if that makes sense).
我将在您的列表中添加第 2) 项,您只需
这样做即可完全禁用突出显示。 CellList 上还有两个与悬停相关的
setSkip
函数。I'll just add for number 2) on your list, you can simply do
That completely disables highlighting. There are also two more
setSkip
-functions on CellList related to hovering.CellTable 可以通过 CSS 设置样式:如何我可以设置 gwt 2.1 CellTables 标题的样式吗?
要禁用突出显示,只需将悬停 CSS 属性设置为空。
可能 - 尝试调整
.cellTableSelectedRow
和.cellTableSelectedRowCell
。这是原始的 CellTable.css: http://www.google.com/codesearch/p?hl=en#A1edwVHBClQ/user/src/com/google/gwt/user/cellview/client/CellTable.css&q=cellTableLastColumn&d=8
CellTable can be styled via CSS: How do I style a gwt 2.1 CellTables headers?
To disable highlighting just set the hover CSS property to nothing.
Possibly - try tweaking the
.cellTableSelectedRow
and.cellTableSelectedRowCell
.Here is the original CellTable.css: http://www.google.com/codesearch/p?hl=en#A1edwVHBClQ/user/src/com/google/gwt/user/cellview/client/CellTable.css&q=cellTableLastColumn&d=8