From af3394d35a253fd3dadea23f98aa36a616f11c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 27 Mar 2020 11:57:02 +0100 Subject: [PATCH] [apps/code] Better event handling for autocompletion --- apps/code/python_text_area.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/code/python_text_area.cpp b/apps/code/python_text_area.cpp index 758b70326..46988f079 100644 --- a/apps/code/python_text_area.cpp +++ b/apps/code/python_text_area.cpp @@ -209,8 +209,7 @@ KDRect PythonTextArea::ContentView::dirtyRectFromPosition(const char * position, bool PythonTextArea::handleEvent(Ion::Events::Event event) { if (m_contentView.isAutocompleting()) { // Handle event with autocompletion - if (event == Ion::Events::Toolbox || event == Ion::Events::Var) { - } else if (event == Ion::Events::Right + if (event == Ion::Events::Right || event == Ion::Events::ShiftRight || event == Ion::Events::OK) { @@ -221,12 +220,26 @@ bool PythonTextArea::handleEvent(Ion::Events::Event event) { scrollToCursor(); return true; } + } else if (event == Ion::Events::Toolbox + || event == Ion::Events::Var + || event == Ion::Events::Shift + || event == Ion::Events::Alpha + || event == Ion::Events::OnOff) + { } else { removeAutocompletion(); m_contentView.reloadRectFromPosition(m_contentView.cursorLocation(), false); + if (event == Ion::Events::Back) { + // Do not process the event more + return true; + } } } - return TextArea::handleEvent(event); + bool result = TextArea::handleEvent(event); + if (event == Ion::Events::Backspace) { + addAutocompletion(); + } + return result; } bool PythonTextArea::handleEventWithText(const char * text, bool indentation, bool forceCursorRightOfText) {