Fixed a bug in the input filtering.

This commit is contained in:
The Wobbler 2024-11-20 16:20:04 +01:00
parent 74b95d8cf9
commit 708cbe6fc8

View file

@ -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()