Community
Participate
Working Groups
I am working on a table viewer that keeps track of the scroll bar and loads content into the table dynamically as the user scrolls to the end of the table. Items could be added/removed from the table as the user scrolls. To maintain the position of the table, I call setTopIndex at the end of the update. I have created a small testcase to simulate the process. Here's my testcase to demonstrate the problem: public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10,10,200,200); final Table table = new Table(shell, SWT.NONE); table.setBounds(10,10,100,100); for (int i = 0; i < 99; i++) { new TableItem(table, SWT.NONE).setText("item " + i); } table.setTopIndex(20); shell.open(); System.out.println("top visible index: " + table.getTopIndex()); for (int i = 0; i < 5; i++) { new TableItem(table, SWT.NONE).setText("item " + i); } table.setTopIndex(40); System.out.println("top visible index: " + table.getTopIndex()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } Table.setTopIndex fails to position to the correct table item if new items are added to the table after the shell is opened. The first call to setTopIndex succeeds. The table is correctly positioned at item 20. After adding new table items to the table, calling setTopTable(40) has no effect. Calling getTopIndex continues to return 20. Expected Result: Calling setTopIndex(40) should move table item #40 to the top of the table. Calling getTopIndex after should return 40. If the last 5 items are added before the shell is opened, setTopIndex to 40 will also succeed. The testcase works as expected on Windows.
Billy, I believe this is a dup ...
I can reproduce this problem using GtkTreeView. Running an event loop after adding items to the table works around the problem. I filed the following bug upstream: http://bugzilla.gnome.org/show_bug.cgi?id=164749
Hi Billy - Again, is it possible to force the setTopIndex to take effect without running the event loop? Thanks Samantha
Fixed in HEAD for 3.2 RC1.