How to set the selection color of a CellList widget?

513 views
Skip to first unread message

Rod Trendy

unread,
Aug 14, 2011, 5:31:22 PM8/14/11
to Google Web Toolkit
Hello everyone,

I can't help it anymore. I am really stuck on the CellList. Creating
and working with a CellList is quite simple, but I can't change the
style of the CellList.

I search the internet via Google but I couldn't find any results that
'really' helped me out. I just want to be able to change the
background color of a selected cell, but whatever I try the color
won't change from yellow to blue. All I've got so far is changing the
whole background of the celllist into blue (including the cells which
are not selected) but that's getting me nowhere.

Please, can anyone help me out? I really would like to have a step by
step guide for this problem. I am exhausted :(

Regards, Rod

Michael Allan

unread,
Aug 15, 2011, 5:14:49 AM8/15/11
to Google Web Toolkit
Hi Rod,

I found I had to disable keyboard selection.
http://zelea.com/project/votorola/a/count/resource/SacSelectionV.java

sacListV.setKeyboardSelectionPolicy(
HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.
// BOUND_TO_SELECTION );
//// causes odd coloured (yellow) background to appear on first click
DISABLED );

Otherwise I had no problem with yellow. My selections are blue.
Click on the ugly, maroon coloured button at top left. See the popup:
http://zelea.com/y/vw/xf/#c=DV&s=G!p!sandbox

--
Michael Allan

Toronto, +1 416-699-9528
http://zelea.com/

Michael Allan

unread,
Aug 15, 2011, 5:29:04 AM8/15/11
to Google Web Toolkit
PS - I should have mentioned that we're not inheriting any "theme"
module: http://zelea.com/project/votorola/a/xf/Entry.gwt.xml

Rod Trendy wrote:
> I can't help it anymore. I am really stuck on the CellList. Creating
> and working with a CellList is quite simple, but I can't change the
> style of the CellList.
>

> ...

ozgur aydinli

unread,
Aug 17, 2011, 4:45:10 AM8/17/11
to Google Web Toolkit
Hi Rod,

You can extend CellList.Resources interface and create the cell list
with your new Resources.


public interface MyCellListResources extends CellList.Resources {

@Source("MyCellList.css")
Style cellListStyle();
}

and in your MyCellList.css override all of the rules and change what
ever you want:

.cellListWidget {

}

.cellListEvenItem {
cursor: pointer;
zoom: 1;
}

.cellListOddItem {
cursor: pointer;
zoom: 1;
}

.cellListKeyboardSelectedItem {
background: red;
<------------------------------------------------------ This is what
you are looking for.
}

@sprite .cellListSelectedItem {
gwt-image: 'cellListSelectedBackground';
background-color: #628cd5;
color: white;
height: auto;
overflow: visible;
}


And finally,

CellList.Resources resources = GWT.create(MyCellListResources.class);
CellList<Contact> cellList = new CellList<Contact>(new ContactCell(),
resources);


You should see a red background when you select an item from the
cellist.
Reply all
Reply to author
Forward
0 new messages