How do you change the mouse to selection?

In GWT, I use CellTable.

When you hover over a CellTable, it highlights each row.

How to change mouse selection behavior? In particular:

  • change highlight color
  • disable / enable
  • select only a specific grid element in your cursor (instead of the entire row)

(The current hack I have is to create a bunch of 1-column width cellular tables and add them to the VerticalPanel layout ... creating the illusion that there is one CellTable and it selects each grid according to your cursor. Is that bad? Why? performance?)

+7
source share
3 answers

You will notice that CellTable uses a ResourceBundle, which means that all css styles become confusing ... this makes it difficult to redefine styles.

The CellTable constructor will actually allow you to override the standard ResourceBundle. So, first you need to create your own resource package as follows:

public interface CellTableResources extends Resources { public CellTableResources INSTANCE = GWT.create(CellTableResources.class); /** * The styles used in this widget. */ @Source("CellTable.css") CellTable.Style cellTableStyle(); } 

Then you need to create your own CSS file. I recommend copying the CellTable style directly into your project and using it 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 you style first, and then you simply load it into the CellTable constructor as follows:

  CellTableResources.INSTANCE.cellTableStyle().ensureInjected(); myCellTable = new CellTable<T>(Integer.MAX_VALUE,CellTableResources.INSTANCE); 

In particular, you will want to customize these styles:

  • cellTableKeyboardSelectedRow
  • cellTableKeyboardSelectedRowCell
  • cellTableSelectedRow
  • cellTableSelectedRowCell
  • cellTableKeyboardSelectedCell

It is important to note that the cell table distinguishes between "selected row" and "selected keyboard." The selected row is the selected actual row (i.e. via SelectionModel). The selected keyboard string refers to what is highlighted when the user presses the up / down key, but does not mean that the string is actually selected (if that makes sense).

+17
source

I just add for number 2) to my list, you can just do

 cellList.setSkipRowHoverStyleUpdate(true) 

This completely disables the selection. CellList has two more setSkip functions related to freezing.

+4
source
  • CellTable can be styled with CSS: How do I create gwt 2.1 header headers?

  • To turn off selection, just set the CSS hover property to nothing.

  • Perhaps try .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

+1
source

All Articles