65 self.__targetSearchFlags = 0 |
65 self.__targetSearchFlags = 0 |
66 self.__targetSearchExpr = "" |
66 self.__targetSearchExpr = "" |
67 self.__targetSearchStart = 0 |
67 self.__targetSearchStart = 0 |
68 self.__targetSearchEnd = -1 |
68 self.__targetSearchEnd = -1 |
69 self.__targetSearchActive = False |
69 self.__targetSearchActive = False |
|
70 |
|
71 self.userListActivated.connect(self.__completionListSelected) |
70 |
72 |
71 def setLexer(self, lex=None): |
73 def setLexer(self, lex=None): |
72 """ |
74 """ |
73 Public method to set the lexer. |
75 Public method to set the lexer. |
74 |
76 |
1177 Public method called when the editor loses focus. |
1179 Public method called when the editor loses focus. |
1178 |
1180 |
1179 @param event event object (QFocusEvent) |
1181 @param event event object (QFocusEvent) |
1180 """ |
1182 """ |
1181 if self.isListActive(): |
1183 if self.isListActive(): |
1182 self.cancelList() |
1184 if event.reason() == Qt.ActiveWindowFocusReason: |
|
1185 aw = QApplication.activeWindow() |
|
1186 if aw is None or aw.parent() is not self: |
|
1187 self.cancelList() |
|
1188 else: |
|
1189 self.cancelList() |
1183 |
1190 |
1184 super().focusOutEvent(event) |
1191 super().focusOutEvent(event) |
1185 |
1192 |
1186 def event(self, evt): |
1193 def event(self, evt): |
1187 """ |
1194 """ |
1257 |
1264 |
1258 self.SendScintilla(QsciScintilla.SCI_AUTOCSETSEPARATOR, |
1265 self.SendScintilla(QsciScintilla.SCI_AUTOCSETSEPARATOR, |
1259 ord(self.UserSeparator)) |
1266 ord(self.UserSeparator)) |
1260 self.SendScintilla(QsciScintilla.SCI_USERLISTSHOW, id, |
1267 self.SendScintilla(QsciScintilla.SCI_USERLISTSHOW, id, |
1261 self._encodeString(self.UserSeparator.join(lst))) |
1268 self._encodeString(self.UserSeparator.join(lst))) |
|
1269 |
|
1270 ########################################################################### |
|
1271 ## work-arounds for buggy behavior |
|
1272 ########################################################################### |
|
1273 |
|
1274 def __completionListSelected(self, id, txt): |
|
1275 """ |
|
1276 Private slot to handle the selection from the completion list. |
|
1277 |
|
1278 Note: This works around an issue of some window managers taking |
|
1279 focus away from the application when clicked inside a completion |
|
1280 list but not giving it back when an item is selected via a |
|
1281 double-click. |
|
1282 |
|
1283 @param id the ID of the user list (integer) |
|
1284 @param txt the selected text (string) |
|
1285 """ |
|
1286 self.activateWindow() |
1262 |
1287 |
1263 ########################################################################### |
1288 ########################################################################### |
1264 ## utility methods |
1289 ## utility methods |
1265 ########################################################################### |
1290 ########################################################################### |
1266 |
1291 |