Bug 240529 - Table.getItem(Point) returns null when table size is too small
Summary: Table.getItem(Point) returns null when table size is too small
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-11 15:07 EDT by Heath Borders CLA
Modified: 2021-11-12 11:39 EST (History)
3 users (show)

See Also:


Attachments
Shows getItem(Point) returning null even when given a point over the item's reported client area (1.29 KB, text/plain)
2008-07-16 23:54 EDT, Heath Borders CLA
no flags Details
Snippet (1.54 KB, text/plain)
2009-05-27 00:42 EDT, Carolyn MacLeod CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Heath Borders CLA 2008-07-11 15:07:47 EDT
Table.getItem(Point) depends on the size of the table.  If the table has a size that provides enough client area to have the given point be visible in the client area, then it returns a table item.  However, if the table's client area is smaller than the given point, Table.getItem returns null.

Table.getItem's documentation says that the given point must be in the coordinate system of the table, but doesn't say anything about the client area being large enough to contain the point being given to it.

For compatibility reasons, the documentation should be updated.

Attached is an example program.
Comment 1 Bogdan Gheorghe CLA 2008-07-16 17:21:15 EDT
We're missing the example you said you would attach ...
Comment 2 Heath Borders CLA 2008-07-16 23:54:16 EDT
Created attachment 107695 [details]
Shows getItem(Point) returning null even when given a point over the item's reported client area

So sorry, I have no idea why this didn't initially attach.

This is the output on windows xp (notice the null at the end of the second line):
TableItem bounds with shell (0, 0), table(0, 0): Rectangle {4, 0, 8, 14}
Get item at tableItem center point with shell (0, 0), table (0, 0): null
TableItem bounds with shell(0, 0), table(100, 100): Rectangle {4, 0, 8, 14}
Get item at tableItem center point with shell (0, 0), table (100, 100): TableItem {}


This bug does not appear on a Mac running 10.5.4 (notice that it is non-null at the end of the second line):
TableItem bounds with shell (0, 0), table (0, 0): Rectangle {4, 0, 0, 18}
Get item at tableItem center point with shell (0, 0), table (0, 0): TableItem {}
TableItem bounds with shell (0, 0), table (100, 100): Rectangle {4, 0, 0, 18}
Get item at tableItem center point with shell (0, 0), table (100, 100): TableItem {}
Comment 3 Carolyn MacLeod CLA 2009-05-26 17:23:35 EDT
I can't doc this unless the expected behavior is consistent across platforms.

The Windows behavior (i.e. point only counts if it's visible) makes sense because typically, getItem(Point) is used to determine if a mouse point is within an item.

If this is the intended behavior, then the doc could say something like:
"The point is in the coordinate system of the receiver, and must be contained within a visible portion of the item."

The Mac behavior seems wrong, and I think it should be made consistent with the Windows behavior.

Steve or Silenio, do you agree? If you do agree that the Windows behavior is what was intended, then should I go ahead and commit the new javadoc sentence above?
Comment 4 Steve Northover CLA 2009-05-26 18:15:20 EDT
It's a strange case.  The table is size zero so the client area is also zero.  Windows seems right.

Your sentence is wrong and it invalidates this Javadoc:

 * <p>
 * The item that is returned represents an item that could be selected by the user.
 * For example, if selection only occurs in items in the first column, then null is 
 * returned if the point is outside of the item. 
 * Note that the SWT.FULL_SELECTION style hint, which specifies the selection policy,
 * determines the extent of the selection.
 * </p>
Comment 5 Carolyn MacLeod CLA 2009-05-27 00:12:34 EDT
The sentence isn't wrong (maybe it's not clear, though <g>).
It is trying to state that there is an additional constraint that the point must be in a visible part of the item.

In other words, the method returns an item if both of these criteria are met:
a) the point is within the extent of the selection as defined by the selection policy,
AND b) the point is visible

If both are true then we have an item that could be selected by the user.
Comment 6 Carolyn MacLeod CLA 2009-05-27 00:42:27 EDT
Created attachment 137268 [details]
Snippet

Here is a slightly less strange case, where the table size is non-zero, and it is smaller than the tableItem size. (i.e. some of the item is not visible).

Click on the item. Console output shows that if the point is in an invisible spot (i.e. the center of the item) then getItem(Point) returns null. But if it's visible (mouse point) then getItem(Point) returns the item.

Now click anywhere on the shell's client area (this just slams the table size to 100 x 100). Now click on the item and notice that getItem(Point) returns the item if the point is at the center of the item.
Comment 7 Steve Northover CLA 2009-05-27 17:00:00 EDT
CAR, the documentation states that getItem() returns the item that could be selected by the user.  If you make the table FULL_SELECTION, then the item should be found.  Am I missing something?
Comment 8 Carolyn MacLeod CLA 2009-05-27 17:33:41 EDT
Yes. If the point is within the bounds of the item, but not within the client area of the table, then Windows returns null, and Mac returns the item.

We need to decide which behavior is correct, and make all platforms conform, and then see if we have to doc it.

Anyhow, not for 3.5.
Comment 9 Heath Borders CLA 2010-04-26 11:51:31 EDT
Any shot for 3.6?
Comment 10 Carolyn MacLeod CLA 2010-04-26 12:39:17 EDT
Sorry, not for 3.6. Is it causing you real problems that you can't work around?
Comment 11 Heath Borders CLA 2010-04-26 13:36:15 EDT
No, I worked around it once I found it initially.  I just saw that it didn't have a target and was curious.
Comment 12 Eclipse Webmaster CLA 2019-09-06 16:16:25 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.