Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table: set "focused" row
Table: set "focused" row [message #728708] Fri, 23 September 2011 13:50 Go to next message
Thomas Singer is currently offline Thomas Singer
Messages: 75
Registered: July 2009
Member
On Windows, my SWT tables show a dotted border around the "focused" row. This seems to always be the first row initially, not matter what entry I select initially. How can I set the "focused" row to match the selected row?
Re: Table: set "focused" row [message #730822 is a reply to message #728708] Thu, 29 September 2011 05:22 Go to previous messageGo to next message
Thomas Singer is currently offline Thomas Singer
Messages: 75
Registered: July 2009
Member
Does no one have an idea?
Re: Table: set "focused" row [message #730972 is a reply to message #730822] Thu, 29 September 2011 12:01 Go to previous message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
Hi,

I see what you're describing. I don't think this is a bug, as there
isn't necessarily a link between the selected item(s) and the focus
item. The focus item is just the place from which keyboard navigations
are resolved.

There isn't a way to set the focus item. A snippet like the one below
can be used to draw focus on an item, but windows still considers the
top item to have the logical focus. I couldn't find an existing feature
request to enable this, so if you want you can log one at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform&component=SWT&bug_severity=enhancement
(I don't know if this is natively supported on all platforms).

public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
new Text(shell, SWT.SINGLE).setLayoutData(new GridData(100,30));
final Table table = new Table(shell, SWT.MULTI);
table.setLayoutData(new GridData(200,200));
new TableItem(table, SWT.NONE).setText("One");
new TableItem(table, SWT.NONE).setText("Two");
new TableItem(table, SWT.NONE).setText("Three");
table.select(1);
table.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
int index = table.indexOf((TableItem)event.item);
if (index == 1 && table.isFocusControl()) {
event.detail |= SWT.FOCUSED;
} else {
event.detail &= ~SWT.FOCUSED;
}
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant


On 9/29/2011 5:22 AM, Thomas Singer wrote:
> Does no one have an idea?
Previous Topic:Multiline TreeItems
Next Topic:is it possible to calculate a list index from a mouse point
Goto Forum:
  


Current Time: Fri Jul 25 03:08:14 EDT 2014

Powered by FUDForum. Page generated in 0.02108 seconds