Change listener of SourceCodeEditor's suggester

Hi! The suggester of SourceCodeEditor in text mode listens “Ctrl+Space” hotkeys. How can I change it to other hotkey combination or even to some character listener? I want to add “user mention” functionality like in Twitter, where you write “@” symbol and It shows you users. Cuba version is 6.8.6.

Hello!

Unfortunately, the key combination is hardcoded on the client-side and there is no API for changing the character that triggers a suggester.

how can I add this functionality? Any ideas

You can extend CubaSuggesterConnector and provide your logic to trigger suggestions.

  1. Add web-toolkit module to your project.
  2. Create “client” package there and extend CubaSuggesterConnector. See example: 4.5.6.4. Creating a GWT component.
    @Connect(SuggestionExtension.class)
    public class MySuggesterConnector extends CubaSuggesterConnector {
    
  3. Override handleKeyboard() method and handle key press events.
    @Connect(SuggestionExtension.class)
    public class MySuggesterConnector extends CubaSuggesterConnector {     
    
        @Override
        public Command handleKeyboard(JavaScriptObject data, int hashId, String keyString, int keyCode,
                                      GwtAceKeyboardEvent e) {
            return super.handleKeyboard(data, hashId, keyString, keyCode, e);
        }
    }
    
1 Like

Thanks!