@Test public void testGetOnKeyDownWhenSuggestWidgetIsNotVisibleAndKeyCodeIsEsc() { final MonacoStandaloneCodeEditor codeEditor = mock(MonacoStandaloneCodeEditor.class); final NativeEvent event = mock(NativeEvent.class); when(event.getKeyCode()).thenReturn(9); when(codeEditor.isSuggestWidgetVisible()).thenReturn(false); domElement.getOnKeyDown(codeEditor).call(event); verify(codeEditor, never()).trigger("keyboard", "cursorHome"); verify(codeEditor, never()).trigger("keyboard", "cursorEnd"); verify(event, never()).stopPropagation(); verify(event, never()).preventDefault(); }
MonacoStandaloneCodeEditor.CallbackFunction getOnKeyDown(final MonacoStandaloneCodeEditor codeEditor) { return event -> { boolean isSuggestWidgetVisible = codeEditor.isSuggestWidgetVisible(); final boolean isEsc = event.getKeyCode() == 9; if (isSuggestWidgetVisible && isEsc) { codeEditor.trigger("keyboard", "cursorHome"); codeEditor.trigger("keyboard", "cursorEnd"); event.stopPropagation(); event.preventDefault(); } }; }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { MonacoStandaloneCodeEditor.CallbackFunction getOnKeyDown(final MonacoStandaloneCodeEditor codeEditor) { return event -> { boolean isSuggestWidgetVisible = codeEditor.isSuggestWidgetVisible(); final boolean isEsc = event.getKeyCode() == 9; if (isSuggestWidgetVisible && isEsc) { codeEditor.trigger("keyboard", "cursorHome"); codeEditor.trigger("keyboard", "cursorEnd"); event.stopPropagation(); event.preventDefault(); } }; } }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { MonacoStandaloneCodeEditor.CallbackFunction getOnKeyDown(final MonacoStandaloneCodeEditor codeEditor) { return event -> { boolean isSuggestWidgetVisible = codeEditor.isSuggestWidgetVisible(); final boolean isEsc = event.getKeyCode() == 9; if (isSuggestWidgetVisible && isEsc) { codeEditor.trigger("keyboard", "cursorHome"); codeEditor.trigger("keyboard", "cursorEnd"); event.stopPropagation(); event.preventDefault(); } }; } MonacoEditorDOMElement(final MonacoEditorWidget widget,
                                  final GridLayer gridLayer,
                                  final GridWidget gridWidget,
                                  final SessionManager sessionManager,
                                  final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                  final Function<GridCellTuple, Command> hasNoValueCommand,
                                  final Function<GridCellValueTuple, Command> hasValueCommand); }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { MonacoStandaloneCodeEditor.CallbackFunction getOnKeyDown(final MonacoStandaloneCodeEditor codeEditor) { return event -> { boolean isSuggestWidgetVisible = codeEditor.isSuggestWidgetVisible(); final boolean isEsc = event.getKeyCode() == 9; if (isSuggestWidgetVisible && isEsc) { codeEditor.trigger("keyboard", "cursorHome"); codeEditor.trigger("keyboard", "cursorEnd"); event.stopPropagation(); event.preventDefault(); } }; } MonacoEditorDOMElement(final MonacoEditorWidget widget,
                                  final GridLayer gridLayer,
                                  final GridWidget gridWidget,
                                  final SessionManager sessionManager,
                                  final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                  final Function<GridCellTuple, Command> hasNoValueCommand,
                                  final Function<GridCellValueTuple, Command> hasValueCommand); void setupElements(); @Override void initialise(final GridBodyCellRenderContext context); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override @SuppressWarnings("unchecked") void flush(final String value); }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { MonacoStandaloneCodeEditor.CallbackFunction getOnKeyDown(final MonacoStandaloneCodeEditor codeEditor) { return event -> { boolean isSuggestWidgetVisible = codeEditor.isSuggestWidgetVisible(); final boolean isEsc = event.getKeyCode() == 9; if (isSuggestWidgetVisible && isEsc) { codeEditor.trigger("keyboard", "cursorHome"); codeEditor.trigger("keyboard", "cursorEnd"); event.stopPropagation(); event.preventDefault(); } }; } MonacoEditorDOMElement(final MonacoEditorWidget widget,
                                  final GridLayer gridLayer,
                                  final GridWidget gridWidget,
                                  final SessionManager sessionManager,
                                  final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                  final Function<GridCellTuple, Command> hasNoValueCommand,
                                  final Function<GridCellValueTuple, Command> hasValueCommand); void setupElements(); @Override void initialise(final GridBodyCellRenderContext context); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override @SuppressWarnings("unchecked") void flush(final String value);  }