How to detect double mouse click in table cell? [message #463351] |
Fri, 04 November 2005 05:39 |
Eclipse User |
|
|
|
Originally posted by: siegfried.heintze.com
The following code works with a single click. How do I modify it so my
listener only executes when a single table cell has been double clicked?
I tried adding a MouseListener but that will only give me coordinates and
not the contents of the table cell. If I have coordinates, how do I get the
table cell contents?
Thanks,
Siegfried
table = new Table(this, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(sash, 0);
data.right = new FormAttachment(100, 0);
table.setLayoutData(data);
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent event){
if(table.getSelectionCount()==1){
TableItem item =table.getSelection()[0];
String urlTarget = item.getText();
}
}
});
new TableColumn(table, 0).setText("Name");
new TableColumn(table, 1).setText("Value");
new TableColumn(table, 2).setText("Text");
|
|
|
|
|
Re: How to detect double mouse click in table cell? [message #463369 is a reply to message #463365] |
Fri, 04 November 2005 15:50 |
Eclipse User |
|
|
|
Originally posted by: siegfried.heintze.com
Ricky,
That worked! Now, why is it that getSelection returns me an array of 1? I
can only get the contents of the first column! How do I get the second
column?
Thanks,
Siegfried
"Ricky" <ImmortalRick@gmx.de> wrote in message
news:op.szpqz32maudqvk@localhost.localdomain...
> > table.addSelectionListener(new SelectionAdapter(){
> > public void widgetSelected(SelectionEvent event){
> > if(table.getSelectionCount()==1){
> > TableItem item =table.getSelection()[0];
> > String urlTarget = item.getText();
> > }
> > }
> > });
>
> Overwrite widgetDefaultSelected(...) instead of widgetSelected(...). Let
> me be suggest you to implement interfaces from scratch the first time you
> use them. This way you figure out what information is provided by the
> event source. The Adapter classes are for convenience only when you know
> what you do not want implement.
>
> Ricky
|
|
|
|
Powered by
FUDForum. Page generated in 0.03215 seconds