Community
Participate
Working Groups
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.
We're missing the example you said you would attach ...
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 {}
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?
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>
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.
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.
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?
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.
Any shot for 3.6?
Sorry, not for 3.6. Is it causing you real problems that you can't work around?
No, I worked around it once I found it initially. I just saw that it didn't have a target and was curious.
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.