Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table mouse move event coords wrong for GTK
Table mouse move event coords wrong for GTK [message #449950] Tue, 01 February 2005 10:29 Go to next message
Rajeev Sudra is currently offline Rajeev SudraFriend
Messages: 30
Registered: July 2009
Member
Dear all,

I am experiencing a problem finding TableItem's for coords in GTK Linux, Eclipse 3.0.1.

given the following method:

private TableItem findTableItemAt(int x, int y) {
Point pt = new Point(x, y);
Rectangle clientRect = table.getClientArea();
int columns = table.getColumnCount();
int start = table.getTopIndex();
int end = table.getItemCount();
for (int row = start; row < end; row++) {
TableItem item = table.getItem(row);
for (int column = 0; column < columns; column++) {
Rectangle rect = item.getBounds(column);
if (rect.y > clientRect.y + clientRect.height)
return null;
if (rect.contains(pt))
return item;
}
}
return null;
}

where x and y are taken directly from the SWT.MouseMove Event and the table control displays a header.

This methods client finds the TableItem at the supplied coords and add an image to it while removing it from any other TableItems. The overall effect is that as the user moves the mouse around the Table, an image moves with the mouse appearing in the TableItem nearest to the current mouse coords.

This method works in Windows but not in GTK. When the mouse is over a TableItem, the image is add to the TableItem directly above it. I think that the table header is messing up the coordinate calculation for GTK. If I add the following to the first line, the problem is corrected only for GTK :

private TableItem findTableItemAt(int x, int y) {
Point pt = new Point(x, y + table.getHeaderHeight());
...

I don't really want to resort to a conditional check for the Windowing system, I think that the code should just work (unless I am doing something wrong!), it used to work in Eclipse 2.0.1 before migration to 3.0.1. Has the contract changed? Or does this sound like a bug?

Any help would be appreciated.
Regards
Raj
Re: Table mouse move event coords wrong for GTK [message #449956 is a reply to message #449950] Tue, 01 February 2005 15:36 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Raj,

You're seeing a bug that existed in 3.0.1 but is fixed in the 3.1 stream.
Unfortunately if you are stuck to using 3.0.1 then I cannot suggest a
graceful workaround beyond checking for this context (running linux-gtk,
header is visible, 2.1.3 < swt version < 3.1) and adjusting accordingly.

Grant

"Rajeev Sudra" <rsudra@hotmail.com> wrote in message
news:ctnlmi$jjv$1@www.eclipse.org...
> Dear all,
>
> I am experiencing a problem finding TableItem's for coords in GTK Linux,
Eclipse 3.0.1.
>
> given the following method:
>
> private TableItem findTableItemAt(int x, int y) {
> Point pt = new Point(x, y);
> Rectangle clientRect = table.getClientArea();
> int columns = table.getColumnCount();
> int start = table.getTopIndex();
> int end = table.getItemCount();
> for (int row = start; row < end; row++) {
> TableItem item = table.getItem(row);
> for (int column = 0; column < columns; column++) {
> Rectangle rect = item.getBounds(column);
> if (rect.y > clientRect.y + clientRect.height)
> return null;
> if (rect.contains(pt))
> return item;
> }
> }
> return null;
> }
>
> where x and y are taken directly from the SWT.MouseMove Event and the
table control displays a header.
>
> This methods client finds the TableItem at the supplied coords and add an
image to it while removing it from any other TableItems. The overall effect
is that as the user moves the mouse around the Table, an image moves with
the mouse appearing in the TableItem nearest to the current mouse coords.
>
> This method works in Windows but not in GTK. When the mouse is over a
TableItem, the image is add to the TableItem directly above it. I think that
the table header is messing up the coordinate calculation for GTK. If I add
the following to the first line, the problem is corrected only for GTK :
>
> private TableItem findTableItemAt(int x, int y) {
> Point pt = new Point(x, y + table.getHeaderHeight());
> ...
>
> I don't really want to resort to a conditional check for the Windowing
system, I think that the code should just work (unless I am doing something
wrong!), it used to work in Eclipse 2.0.1 before migration to 3.0.1. Has the
contract changed? Or does this sound like a bug?
>
> Any help would be appreciated.
> Regards
> Raj
>
Previous Topic:Change mouse pinter
Next Topic:Button image disappears when I call Button.setEnabled(false)
Goto Forum:
  


Current Time: Fri Apr 19 08:34:17 GMT 2024

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

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

Back to the top