Fix esc handling on BaseKeyParser

This commit is contained in:
Florian Bruhin 2014-05-09 15:28:07 +02:00
parent d4672f324a
commit e09b34a744

View File

@ -18,6 +18,7 @@
"""Base class for vim-like keysequence parser.""" """Base class for vim-like keysequence parser."""
import re import re
import string
import logging import logging
from functools import partial from functools import partial
@ -148,11 +149,17 @@ class BaseKeyParser(QObject):
Return: Return:
True if event has been handled, False otherwise. True if event has been handled, False otherwise.
""" """
logging.debug("Got key: {} / text: '{}'".format(e.key(), e.text())) txt = e.text()
txt = e.text().strip() key = e.key()
if not txt or e.key() == Qt.Key_Backspace: logging.debug("Got key: {} / text: '{}'".format(key, txt))
# backspace is counted as text... if key == Qt.Key_Escape:
logging.debug("Ignoring, no text") logging.debug("Escape pressed, discarding '{}'.".format(
self._keystring))
self._keystring = ''
return
if txt not in (string.ascii_letters + string.digits +
string.punctuation):
logging.debug("Ignoring, no text char")
return False return False
self._stop_delayed_exec() self._stop_delayed_exec()