Bug 410427 - org.eclipse.swt.widgets.Table.getTopIndex() returns wrong value when selecting the last not fully visible row
Summary: org.eclipse.swt.widgets.Table.getTopIndex() returns wrong value when selectin...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2013-06-11 05:23 EDT by Sorin D. CLA
Modified: 2020-05-26 03:03 EDT (History)
2 users (show)

See Also:


Attachments
TestSnippet to reproduce this problem (975 bytes, text/x-java)
2014-06-18 09:15 EDT, Niraj Modi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sorin D. CLA 2013-06-11 05:23:27 EDT
I am encountering a wrong behavior of the getTopIndex() method of Table class.

Lets say we have a table with 20 fully visible rows and one more row that is not fully visible. Does not matter how much of this last row is visible. What is important is that the user can select it using his mouse if he wants to.



We have two scenarios:

Scenario 1:
Lets say that last visible row is already selected.The user presses down arrow key, making the table to select the row which was not fully visible and bring it one row above in the UI in order for the user to see it completely. In this scenario the getTopIndex() returns a value equal to:

"index of selected row - 20 - 1"

Scenario 2:
The user selects the row which is not fully visible via a mouse click making the table to bring it one row above in the UI in order for the user to see it completely. In this scenario the getTopIndex() returns a value equal to:

"index of selected row - 20"

As you can see the difference between the two values is 1. In my opinion this is wrong. It should return the same value.
Comment 1 Niraj Modi CLA 2014-06-18 09:15:07 EDT
Created attachment 244329 [details]
TestSnippet to reproduce this problem
Comment 2 Niraj Modi CLA 2014-06-18 09:27:30 EDT
A possible workaround would be to use combination of KeyListerer & MouseListener instead of SelectionListener to get consistent value from Table#getTopIndex() :
table.addKeyListener(new KeyAdapter() {
	@Override
	public void keyPressed(KeyEvent e) {
		System.out.println("KeyPressed: [" + table.getTopIndex() + "]");
	}
});
table.addMouseListener(new MouseAdapter() {
	@Override
	public void mouseDown(MouseEvent e) {
		System.out.println("MouseDown:  [" + table.getTopIndex() + "]");
	}
});
Comment 3 Eclipse Genie CLA 2020-05-25 18:04:43 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.

--
The automated Eclipse Genie.
Comment 4 Sorin D. CLA 2020-05-26 03:03:33 EDT
Its true what they say, that time fixes all things.
Thank you for looking into the actual problem raised.