Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 410427

Summary: org.eclipse.swt.widgets.Table.getTopIndex() returns wrong value when selecting the last not fully visible row
Product: [Eclipse Project] Platform Reporter: Sorin D. <sorin_dia21>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: niraj.modi, sorin_dia21
Version: 3.7Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
TestSnippet to reproduce this problem none

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.