diff libgui/src/m-editor/file-editor-tab.cc @ 28382:2b52e473b6ef stable

fix focus issues in editor due to qt bug with focus proxy chains (bug #57635) * file-editor-tab.cc (file_editor_tab): initialize flag for actuve lists, do not set a focus proxy; (show_auto_completion): set flag for active list; (handle_cursor_moved): test for active list and emit signal if a list was closed * file-editor-tab.h: new flag m_atuoc_active and new signal autoc_closed * file-editor.cc (activate): do not emit signal for focussing current editor tab but call new method reset_focus where the signal is emitted; (handle_editor_state_changed): do not set a focus proxy; (construct): set tab widget as focus proxy; (handle_autoc_cancelled): slot for signal when auto-completion list is cancelled, complete the list for really closing it; (reset_focus): new method for resetting focus to the editor tab (make_file_editor_tab): connect signals for cancelled, completed and closed auto-completion list to related new slots (foucsInEvent): reimplemented event for setting the foucs to the edit tab and its edit area * file-editor.h: new slots handle_autoc_cancelled and reset_focus, reimplemented focusInEvent
author Torsten Lilge <ttl-octave@mailbox.org>
date Tue, 26 May 2020 06:59:45 +0200
parents 1127bcb30e61
children f3200b8cff19 2813ac10ca1e
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Mon May 25 14:53:54 2020 -0700
+++ b/libgui/src/m-editor/file-editor-tab.cc	Tue May 26 06:59:45 2020 +0200
@@ -106,6 +106,7 @@
     m_lexer_apis = nullptr;
     m_is_octave_file = true;
     m_lines_changed = false;
+    m_autoc_active = false;
 
     m_ced = directory_arg;
 
@@ -263,8 +264,6 @@
     if (settings)
       notice_settings (settings, true);
 
-    setFocusProxy (m_edit_area);
-
     // encoding, not updated with the settings
     QString locale_enc_name =
       QString ("SYSTEM (") +
@@ -1447,6 +1446,8 @@
     if (ID != this)
       return;
 
+    m_autoc_active = true;
+
     QsciScintilla::AutoCompletionSource s = m_edit_area->autoCompletionSource ();
     switch (s)
       {
@@ -3022,9 +3023,19 @@
 
   void file_editor_tab::handle_cursor_moved (int line, int col)
   {
+    // Cursor has moved, first check wether an autocompletion list
+    // is active or if it was closed. Scintilla provides signals for
+    // completed or cancelled lists, but not for list that where hidden
+    // due to a new character not matching anymore with the list entries
     if (m_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE))
-      show_auto_completion (this);
-
+      m_autoc_active = true;
+    else if (m_autoc_active)
+      {
+        m_autoc_active = false;
+        emit autoc_closed (); // Tell editor about closed list
+      }
+
+    // Lines changed? Take care of indentation
     if (m_lines_changed)  // cursor moved and lines have changed
       {
         m_lines_changed = false;
@@ -3037,9 +3048,9 @@
           }
       }
 
+    // Update line and column indicator in the status bar
     m_line = line;
     m_col  = col;
-
     m_row_indicator->setNum (line+1);
     m_col_indicator->setNum (col+1);
   }