Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » First key press deleted on macOS
First key press deleted on macOS [message #1839806] Mon, 29 March 2021 10:41 Go to next message
Thomas Krause is currently offline Thomas KrauseFriend
Messages: 2
Registered: March 2021
Junior Member
We have an application where the user should be able to select cells without directly starting to edit them. Instead, editing can be started by just starting typing.

@Override
  protected void addEditingUIConfig() {
    addConfiguration(new AbstractUiBindingConfiguration() {
      @Override
      public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
        // Start editing when user starts typing
        uiBindingRegistry.registerKeyBinding(new LetterOrDigitKeyEventMatcher(),
            new KeyEditAction());
      }
    });
  }


This works fine on Linux. Unfortunately, when the KeyEditAction is triggered on macOS, the text field content is replaced with the first pressed key, then the text field is activated which causes SWT to select all text (the single character) and as soon as the use rpresses more keys the first (selected) character is deleted.

I attached a minimal working example which should demonstrate this behavior.

This was a bit surprising to find out because the code will behave very differently on different platforms.
Re: First key press deleted on macOS [message #1839823 is a reply to message #1839806] Mon, 29 March 2021 14:50 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
The editor activation on key press is enabled by default, so you should be able to reproduce the issue with any editable example provided by NatTable.

IIRC that issue was reported before and I created a ticket with the SWT project. It is the Text implementation on mac that has this issue. Not sure about the state of the ticket and nothing we can do in NatTable to solve this.
Re: First key press deleted on macOS [message #1839824 is a reply to message #1839823] Mon, 29 March 2021 14:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
https://www.eclipse.org/forums/index.php/t/1089421/

This was the topic some years ago if that helps
Re: First key press deleted on macOS [message #1839842 is a reply to message #1839824] Tue, 30 March 2021 05:21 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
This is what we internally do:

// originalCanonicalValue is the Character provided via keypress
this.text.setText(originalCanonicalValue.toString());

int textLength = this.text.getText().length();
this.text.setSelection(textLength, textLength);


I don't know why that code does not work on MacOS. But it seems to be a known issue somehow:
https://stackoverflow.com/questions/46791128/swt-text-field-make-text-focused-at-the-end-of-the-line

You could try to use the MultiLineTextCellEditor and see if that works, as it uses the SWT.MULTI style. There it should work from the SO post. But as I don't have a Mac, I can't test this in any way.

Seems I have not created a ticket for the SWT team. Feel free to create one or check if there is some other solution for this issue on MacOS.
Re: First key press deleted on macOS [message #1840308 is a reply to message #1839842] Mon, 12 April 2021 09:32 Go to previous message
Thomas Krause is currently offline Thomas KrauseFriend
Messages: 2
Registered: March 2021
Junior Member
Thanks! I will try out the workaround with SWT.MULTI and report if this works
Previous Topic:Tracking of data changes
Next Topic:Possible Bug Report for Single Select + Use Checkbox Combobox Cell Editors
Goto Forum:
  


Current Time: Tue Jun 15 14:26:25 GMT 2021

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

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

Back to the top