Click on empty row in a table [message #518961] |
Fri, 05 March 2010 10:11  |
Eclipse User |
|
|
|
HI, I try to detect a click on an empty row in a table in a platform independend way. When I look at the Table implementation I could aks the OS for the selection, but that would mean I have to do that platform dependent (which I want to avoid). Can anyone give me a hint how I could listen to such a click ?
|
|
|
|
|
|
Re: Click on empty row in a table [message #519404 is a reply to message #519345] |
Mon, 08 March 2010 12:50  |
Eclipse User |
|
|
|
I think brute force is the way to go then:
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setBounds(10,10,400,400);
shell.setLayout(new FillLayout());
final Table table = new Table (shell, SWT.V_SCROLL);
for (int i = 0; i < 9; i++) {
new TableItem(table, SWT.NONE).setText("item " + i);
}
table.addListener(SWT.MouseDown, new Listener() { // <---
public void handleEvent(Event event) {
Rectangle bounds = table.getItem(table.getItemCount() -
1).getBounds();
if (bounds.y + bounds.height < event.y) {
System.out.println("clicked below");
}
}
});
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
Grant
"Thomas Kratz" <eiswind@googlemail.com> wrote in message
news:hn33fk$aib$1@build.eclipse.org...
> Its meaningful only with FULL_SELECTION otherwise the table rows that have
romm left over beneath the columns also reply with null on getItem(); and
thats confusing to ths user (and me :)
|
|
|
Powered by
FUDForum. Page generated in 0.05024 seconds