Skip to content

Commit

Permalink
Make the tab key work in the feature autocompleter
Browse files Browse the repository at this point in the history
In the feature select dialog, use the tab key to select a feature from the candidate popup. Use the arrow keys to highlight a feature and then hit the tab key.
re: #804
  • Loading branch information
stannam committed Apr 22, 2022
1 parent 3f1b04d commit c2e1c9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion corpustools/gui/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def __init__(self, header, results, settings, parent=None):
headerIdx += 1
currRow = 0
stop = 0
while stop is not 1 and currRow+1 < len(results):
while stop != 1 and currRow+1 < len(results):
cv = results[currRow][currHeader]
nv = results[currRow+1][currHeader]
if cv != nv:
Expand Down
22 changes: 11 additions & 11 deletions corpustools/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,27 +1414,27 @@ def currentFeature(self):
def event(self, e):
# keyPressEvent() doesn't catch the tab key when pressed so catch it under event
if e.type() == QEvent.KeyPress:
if e.key() == Qt.Key_Tab:
self.tabPressed.emit()
return True
else:
self.keyPressed(e)
return True
# if e.key() == Qt.Key_Tab:
# self.tabPressed.emit()
# return True
# else:
self.keyPressed(e)
return True
return super().event(e)


def keyPressed(self,e):
if self.completer and self.completer.popup().isVisible():
if e.key() in ( Qt.Key_Space, Qt.Key_Enter,
Qt.Key_Return, Qt.Key_Escape,
Qt.Key_Tab, Qt.Key_Backtab): # e.ignore() doesn't work when e.key() == Qt.Key_Tab
if e.key() in (Qt.Key_Space, Qt.Key_Enter,
Qt.Key_Return, Qt.Key_Escape,
Qt.Key_Tab, Qt.Key_Backtab): # e.ignore() doesn't work when e.key() == Qt.Key_Tab
e.ignore()
return
else:
if e.key() in (Qt.Key_Enter, Qt.Key_Return):
if e.key() in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Tab):
self.finalize()
return
isShortcut=((e.modifiers() & Qt.ControlModifier) and e.key()==Qt.Key_E)
isShortcut=((e.modifiers() & Qt.ControlModifier) and e.key() == Qt.Key_E)
if (self.completer is None or not isShortcut):
super().keyPressEvent(e)

Expand Down

1 comment on commit c2e1c9c

@stannam
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also re: #716

Please sign in to comment.