natTable Focus [message #1847815] |
Tue, 09 November 2021 02:43  |
Eclipse User |
|
|
|
Hi all,
requirement : change the selected row color " blue to gray " if nat table is not in focus .
is there any example available in nat table for this kind of implementation ?
or is there any API by nat table that give me the selection/focus status of nat table ?
thanks
|
|
|
Re: natTable Focus [message #1847819 is a reply to message #1847815] |
Tue, 09 November 2021 04:05  |
Eclipse User |
|
|
|
NatTable is a SWT widget. So of course you can check the focus state as with any other SWT widget. For the selection state you need access to the SelectionLayer.
If you want to change the styling when the focus on the NatTable changes, simply implement and register a FocusListener that dynamically changes the styling directly in the ConfigRegistry:
natTable.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
Style style = new Style();
style.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.COLOR_GRAY);
natTable.getConfigRegistry().registerConfigAttribute(
CellConfigAttributes.CELL_STYLE,
style,
DisplayMode.SELECT);
}
@Override
public void focusGained(FocusEvent e) {
Style style = new Style();
style.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.COLOR_BLUE);
natTable.getConfigRegistry().registerConfigAttribute(
CellConfigAttributes.CELL_STYLE,
style,
DisplayMode.SELECT);
}
});
Have in mind that the selection anchor is styled differently.
|
|
|
Powered by
FUDForum. Page generated in 0.02651 seconds