Skip to content

Commit

Permalink
Fix tab autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
AlberLC committed Jun 18, 2022
1 parent 1bc9813 commit c77d2d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions flanarunas/my_qt/combo_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self, parent=None, items=None):

self.lineEdit().textEdited.connect(self._set_completer_items)
self.lineEdit().returnPressed.disconnect() # no add new elements at enter
self.completer.popup().activated.connect(lambda x: print(1, x))

def add_item(self, item: str):
self.items += [item]
Expand All @@ -34,9 +35,10 @@ def delete_item(self, name: str):
self.items = self._items

def event(self, event: QtCore.QEvent) -> bool:
if isinstance(event, QtGui.QKeyEvent) and event.key() == QtCore.Qt.Key_Tab:
if isinstance(event, QtGui.QKeyEvent) and event.key() == QtCore.Qt.Key_Tab and event.type() == QtCore.QEvent.KeyPress:
# noinspection PyUnresolvedReferences
self.completer.activated.emit(self.completer.currentCompletion())
self.completer.activated.emit(self.completer.popup().model().data(self.completer.popup().currentIndex()))
self.setFocus()

return super().event(event)

Expand Down
2 changes: 1 addition & 1 deletion flanarunas/resources/data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}

0 comments on commit c77d2d6

Please sign in to comment.