Comments editor: Allow using the Ctrl+Tab key combo to insert a literal tab

This commit is contained in:
Kovid Goyal 2014-10-08 16:19:26 +05:30
parent 650ea67660
commit edeb8b90bb

View File

@ -385,6 +385,9 @@ class EditorWidget(QWebView): # {{{
def event(self, ev): def event(self, ev):
if ev.type() in (ev.KeyPress, ev.KeyRelease, ev.ShortcutOverride) and ev.key() in ( if ev.type() in (ev.KeyPress, ev.KeyRelease, ev.ShortcutOverride) and ev.key() in (
Qt.Key_Tab, Qt.Key_Escape, Qt.Key_Backtab): Qt.Key_Tab, Qt.Key_Escape, Qt.Key_Backtab):
if (ev.key() == Qt.Key_Tab and ev.modifiers() & Qt.ControlModifier and ev.type() == ev.KeyPress):
self.exec_command('insertHTML', '<span style="white-space:pre">\t</span>')
return True
ev.ignore() ev.ignore()
return False return False
return QWebView.event(self, ev) return QWebView.event(self, ev)