[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: Table issue
|
- From: Shawn Spiars <sspiars@xxxxxxxx>
- Date: Wed, 12 Mar 2008 02:55:52 -0500
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.9 (Windows/20071031)
dnise wrote:
Shawn Spiars wrote:
eclipse.org
Hi
Thanks you advice . but i can't find what i want .assume as follow it's a
table
------------------------------------
| column1 | column2 | column3 |
|-----------------------------------
| ff1 | ff2 | ff3 |
------------------------------------
| kk1 | kk2 | kk3 |
------------------------------------
we can select a row when i click. we can use follow codes to get TableItem
TableItem [] tableItem=table.getSelection();
we can add some Listeners for this tableItem. But it doesn't complete what i
want. we can select a row when i click on ff1 ãff2ãff3ãkk1ãkk2 or kk3.
the function which i want to implement is that trigger some event when i
click on ff3 or kk3 but not ff1,ff2,kk1,kk2.
can i implement it?
thanks
best regards
dnise
You might try using a mouseListener on the table and then determining
the selected cell using the mouseUp event. See snippet below.
table = toolkit.createTable(parent,
SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
table.addMouseListener(new MouseAdapter() {
public void mouseUp(MouseEvent event) {
Point point = new Point(event.x, event.y);
TableItem item = table.getItem(point);
if (item != null) {
int columnCount = table.getColumnCount();
for (int i=0; i < columnCount; i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(point)) {
System.out.println("table item column: " + i);
System.out.println("table item: " + item.getText(i));
}
}
}
}
});