mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
ignore the key stroke if empty, otherwise accept
This commit is contained in:
parent
7541485e87
commit
26e7428f16
1 changed files with 8 additions and 7 deletions
|
@ -4,7 +4,7 @@
|
|||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
from anki.utils import parseTags, canonifyTags, joinTags
|
||||
import re
|
||||
import re, sys
|
||||
|
||||
class TagEdit(QLineEdit):
|
||||
|
||||
|
@ -36,10 +36,11 @@ class TagEdit(QLineEdit):
|
|||
|
||||
def keyPressEvent(self, evt):
|
||||
if evt.key() in (Qt.Key_Enter, Qt.Key_Return):
|
||||
evt.ignore()
|
||||
if not self.text():
|
||||
pass
|
||||
elif self.completer.completionCount():
|
||||
evt.ignore()
|
||||
else:
|
||||
evt.accept()
|
||||
if self.completer.completionCount():
|
||||
self.setText(
|
||||
self.completer.pathFromIndex(self.completer.popup().currentIndex()))
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue