Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » When clicking in a Table, how do I determine which Column was clicked?
When clicking in a Table, how do I determine which Column was clicked? [message #453059] Thu, 20 July 2006 16:18 Go to next message
Eclipse UserFriend
Originally posted by: steve.bayer.hci.utah.edu

The oddity of Table is that it is row-centric. From getSelection() I can
determine the row clicked, but how do I know which column was clicked?

Thanks in advance.
Re: When clicking in a Table, how do I determine which Column was clicked? [message #453060 is a reply to message #453059] Thu, 20 July 2006 16:24 Go to previous messageGo to next message
Eclipse UserFriend
I think there may be a snippet; but in any event, add a MouseListener to yor table, and:

public void mouseDown(final MouseEvent event) {
final Rectangle clientArea = _table.getClientArea();
final Point pt = new Point(event.x, event.y);

_row = _table.getTopIndex();
boolean visible = true;

while (visible && _row < _table.getItemCount()) {
final TableItem item = _table.getItem(_row);

for (_column = 0; _column < _table.getColumnCount(); ++_column) {
final Rectangle rect = item.getBounds(_column);
if (rect.contains(pt)) {
return; // to leave _column, _row correct
}
visible = rect.intersects(clientArea);
}
++_row;
}
}

HTH,
Paul
Re: When clicking in a Table, how do I determine which Column was clicked? [message #453061 is a reply to message #453060] Thu, 20 July 2006 16:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: steve.bayer.hci.utah.edu

Thanks very much.
Re: When clicking in a Table, how do I determine which Column was clicked? [message #453071 is a reply to message #453061] Fri, 21 July 2006 05:01 Go to previous messageGo to next message
Eclipse UserFriend
A slightly better version can be found attached to this bug in short you
only have to check the selected rows and not all rows as done in the
solution in this thread.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=151377

Tom

Steve Bayer schrieb:
> Thanks very much.
>
Re: When clicking in a Table, how do I determine which Column was clicked? [message #453108 is a reply to message #453071] Fri, 21 July 2006 14:10 Go to previous message
Eclipse UserFriend
MM -- good, that's much more efficient in large tables. And works with right-click too (to pop up a
row-dependent menu, e.g.).

Thanks,
Paul
Previous Topic:Making New wizard appears in File->New
Next Topic:Depolying RCP using java Web Start
Goto Forum:
  


Current Time: Tue Jul 15 16:01:00 EDT 2025

Powered by FUDForum. Page generated in 0.07680 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top