How to suppress visual selection and mouse-over in swt.widgets.Table? [message #837396] |
Thu, 05 April 2012 16:13 |
David Hanney Messages: 2 Registered: April 2012 |
Junior Member |
|
|
How do I get rid of org.eclipse.swt.widgets.Table row highlighting on both select and mouse-over?
I want my red and blue backgrounds maintained throughout the table no matter what the user does with the mouse.
This is as near as I can get
(and it is nowhere near)
so any help would be gladly received.
(Windows 7 and swt-3.8M5-win32-win32-x86_64)
Thanks in advance!
David
p.s. I've tried variations on handling SWT.EraseItem as discussed in
"Eclipse Corner Article: Custom Drawing Table and Tree Items".
import java.io.IOException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class TablePain {
public static void main(String[] args) throws IOException {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Color red = display.getSystemColor(SWT.COLOR_RED);
final Color blue = display.getSystemColor(SWT.COLOR_BLUE);
final Table table = new Table(shell, SWT.H_SCROLL | SWT.VIRTUAL
| SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.setItemCount(1000);
for (int x = 0; x < 3; x++) {
final TableColumn column = new TableColumn(table, SWT.NONE);
column.setText("col" + x);
column.setWidth(100);
column.setMoveable(true);
}
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event e) {
TableItem item = (TableItem) e.item;
int y = table.indexOf(item);
item.setText(new String[] { "data0", "data1", "data2" });
for (int x = 0; x < 3; x++) {
boolean isRed = ((x^y)&1)==0;
item.setBackground(x, isRed ? red : blue);
}
}
});
table.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
// Selection:
event.detail &= ~SWT.SELECTED;
// Expect: selection now has no visual effect.
// Actual: selection remains but changes from light blue to white.
// MouseOver:
event.detail &= ~SWT.HOT;
// Expect: mouse over now has no visual effect.
// Actual: behavior remains unchanged.
}
});
shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
[Updated on: Tue, 10 April 2012 09:43] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03410 seconds