Sfoglia il codice sorgente

- autocomplete in Code Editor is finished by hitting either TAB key or ENTER key

Marius Stanciu 6 anni fa
parent
commit
ec75a68976
2 ha cambiato i file con 5 aggiunte e 2 eliminazioni
  1. 1 0
      README.md
  2. 4 2
      flatcamGUI/GUIElements.py

+ 1 - 0
README.md

@@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
 19.03.2019
 
 - added autocomplete for Code editor; TODO: needs to be enabled only when doing Scripts, right now is available for everyone.
+- autocomplete in Code Editor is finished by hitting either TAB key or ENTER key
 - fixed the Gerber.merge() to work for the case when one of the merged Gerber objects solid_geometry type is Polygon and not a list
 
 18.03.2019

+ 4 - 2
flatcamGUI/GUIElements.py

@@ -517,6 +517,7 @@ class FCTextAreaExtended(QtWidgets.QTextEdit):
         if self.completer:
             self.completer.setWidget(self)
         QTextEdit.focusInEvent(self, event)
+
     def set_value(self, val):
         self.setText(val)
 
@@ -555,12 +556,13 @@ class FCTextAreaExtended(QtWidgets.QTextEdit):
                 self.insertPlainText(clip_text)
 
         tc = self.textCursor()
-        if event.key() == Qt.Key_Tab and self.completer.popup().isVisible():
+        if (key == Qt.Key_Tab or key == Qt.Key_Enter or key == Qt.Key_Return) and self.completer.popup().isVisible():
             self.completer.insertText.emit(self.completer.getSelected())
             self.completer.setCompletionMode(QCompleter.PopupCompletion)
             return
+        else:
+            super(FCTextAreaExtended, self).keyPressEvent(event)
 
-        super(FCTextAreaExtended, self).keyPressEvent(event)
         tc.select(QTextCursor.WordUnderCursor)
         cr = self.cursorRect()