QScintilla/QsciScintillaCompat.py

branch
5_4_x
changeset 3240
7cb4665c9c05
parent 3216
001982b9acf9
child 3258
a2bec950a859
--- a/QScintilla/QsciScintillaCompat.py	Fri Jan 31 12:15:02 2014 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Fri Jan 31 12:20:32 2014 +0100
@@ -67,6 +67,8 @@
         self.__targetSearchStart = 0
         self.__targetSearchEnd = -1
         self.__targetSearchActive = False
+        
+        self.userListActivated.connect(self.__completionListSelected)
     
     def setLexer(self, lex=None):
         """
@@ -1179,7 +1181,12 @@
         @param event event object (QFocusEvent)
         """
         if self.isListActive():
-            self.cancelList()
+            if event.reason() == Qt.ActiveWindowFocusReason:
+                aw = QApplication.activeWindow()
+                if aw is None or aw.parent() is not self:
+                    self.cancelList()
+            else:
+                self.cancelList()
         
         super().focusOutEvent(event)
     
@@ -1261,6 +1268,24 @@
                            self._encodeString(self.UserSeparator.join(lst)))
     
     ###########################################################################
+    ## work-arounds for buggy behavior
+    ###########################################################################
+    
+    def __completionListSelected(self, id, txt):
+        """
+        Private slot to handle the selection from the completion list.
+        
+        Note: This works around an issue of some window managers taking
+        focus away from the application when clicked inside a completion
+        list but not giving it back when an item is selected via a
+        double-click.
+        
+        @param id the ID of the user list (integer)
+        @param txt the selected text (string)
+        """
+        self.activateWindow()
+    
+    ###########################################################################
     ## utility methods
     ###########################################################################
     

eric ide

mercurial