Skip to main content



      Home
Home » Eclipse Projects » NatTable » questions about LinkClickConfiguration
questions about LinkClickConfiguration [message #1858731] Tue, 18 April 2023 11:09 Go to next message
Eclipse UserFriend
Hello,

I used the LinkClickConfiguration as explained in the NatTable examples, to add a delete button (with image) on each row.

Is it possible to make it listen to key events besides mouse click?
In our case it needs to respond to space and F2 when the cell is selected with key navigation.

I also noticed that when adding
NatTable :select {
painter-resolution: false;
cell-background-color: #e7f1ff;
}
the LinkClickConfiguration cells always have the selected background color.
Is it possible to avoid this behavior?

Thank you.
Re: questions about LinkClickConfiguration [message #1858746 is a reply to message #1858731] Wed, 19 April 2023 03:09 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
Is it possible to make it listen to key events besides mouse click?


Sure, you just need to add the corresponding key binding. The difference is that you can not determine the coordinates for the action out of the event. You need to determine the coordinates from the SelectionLayer. Below is a snippet how such a binding and action could look like for pressing the space key in the mentioned example. You also need to add a binding for F2.

uiBindingRegistry.registerFirstKeyBinding(new KeyEventMatcher(SWT.SPACE), new IKeyAction() {

    @Override
    public void run(NatTable natTable, KeyEvent event) {
        Collection<ILayerCell> selectedCells = Rendering_cells_as_a_link_and_button.this.gridLayer.getSelectionLayer().getSelectedCells();
        if (selectedCells.size() == 1) {
            ILayerCell cell = selectedCells.iterator().next();
            int rowIndex = cell.getRowIndex();
            int columnIndex = cell.getColumnIndex();

            ListDataProvider<RowDataFixture> dataProvider =
                    Rendering_cells_as_a_link_and_button.this.gridLayer.getBodyDataProvider();

            Object rowObject = dataProvider.getRowObject(rowIndex);
            Object cellData = dataProvider.getDataValue(columnIndex, rowIndex);

            log("Pressed key on cell: " + cellData);
            log("Pressed key on row: " + rowObject + "\n");
        }
    }
});


With regards to the styling question. I suppose it is an issue with the fallthrough in the CSS stuff. As I don't know the rest of your style configuration, I can only assume that you have not specified a background color for the cells with the links. To avoid this I guess you need to specify the background color also for the label in the CSS in normal and selected mode to make it work consistently.
I actually don't use the CSS styling in NatTable, as the NatTable styling capabilities via configurations are much more reliable and performant than the CSS one.
Re: questions about LinkClickConfiguration [message #1858756 is a reply to message #1858746] Wed, 19 April 2023 11:22 Go to previous message
Eclipse UserFriend
Thank you, it worked!
I had to create a CellLabelKeyMatcher (similarly to the CellLabelMouseEventMatcher) which also matched on the link cell label, otherwise the rest of the editors did not respond to space or F2.
We are using the CSS styling because we need to use color constants from the selected eclipse css theme. Specifying the background color in the normal mode fixed the problem.

Best regards,
Edit
Previous Topic:questions about LinkClickConfiguration
Next Topic:Mysterious popup text editor on Linux - ComboBoxCellEditor
Goto Forum:
  


Current Time: Mon May 12 21:40:39 EDT 2025

Powered by FUDForum. Page generated in 0.03957 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top