Fixed a bug in the input filtering.
This commit is contained in:
parent
74b95d8cf9
commit
708cbe6fc8
1 changed files with 6 additions and 3 deletions
|
@ -11,10 +11,13 @@ class BinaryTextEdit(QPlainTextEdit): # rewrite QPlainTextEdit.keyPressEvent be
|
||||||
cursor = self.textCursor()
|
cursor = self.textCursor()
|
||||||
pos = cursor.position()
|
pos = cursor.position()
|
||||||
|
|
||||||
if (pos + 1) % 9 == 0 and event.text() not in {'', None}: # dont overwrite the separator character
|
if not (pos + 1) % 9 == 0 or event.text() in {"", None}: # dont overwrite the separator character
|
||||||
return
|
super().keyPressEvent(event)
|
||||||
|
|
||||||
super().keyPressEvent(event)
|
# skip over the separator character when the cursor is before it.
|
||||||
|
if (pos + 2) % 9 == 0 and not event.text() in {"", None}:
|
||||||
|
cursor.setPosition(pos + 2)
|
||||||
|
self.setTextCursor(cursor)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
|
|
Loading…
Reference in a new issue