mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -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.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
from anki.utils import parseTags, canonifyTags, joinTags
|
from anki.utils import parseTags, canonifyTags, joinTags
|
||||||
import re
|
import re, sys
|
||||||
|
|
||||||
class TagEdit(QLineEdit):
|
class TagEdit(QLineEdit):
|
||||||
|
|
||||||
|
@ -36,10 +36,11 @@ class TagEdit(QLineEdit):
|
||||||
|
|
||||||
def keyPressEvent(self, evt):
|
def keyPressEvent(self, evt):
|
||||||
if evt.key() in (Qt.Key_Enter, Qt.Key_Return):
|
if evt.key() in (Qt.Key_Enter, Qt.Key_Return):
|
||||||
evt.ignore()
|
|
||||||
if not self.text():
|
if not self.text():
|
||||||
pass
|
evt.ignore()
|
||||||
elif self.completer.completionCount():
|
else:
|
||||||
|
evt.accept()
|
||||||
|
if self.completer.completionCount():
|
||||||
self.setText(
|
self.setText(
|
||||||
self.completer.pathFromIndex(self.completer.popup().currentIndex()))
|
self.completer.pathFromIndex(self.completer.popup().currentIndex()))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue