From 708cbe6fc89851e5ebf82ad34029a1d4dbd210ea Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Wed, 20 Nov 2024 16:20:04 +0100 Subject: [PATCH] Fixed a bug in the input filtering. --- binary_text_edit.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/binary_text_edit.py b/binary_text_edit.py index 2d9abc1..b6b2994 100644 --- a/binary_text_edit.py +++ b/binary_text_edit.py @@ -11,10 +11,13 @@ class BinaryTextEdit(QPlainTextEdit): # rewrite QPlainTextEdit.keyPressEvent be cursor = self.textCursor() pos = cursor.position() - if (pos + 1) % 9 == 0 and event.text() not in {'', None}: # dont overwrite the separator character - return + if not (pos + 1) % 9 == 0 or event.text() in {"", None}: # dont overwrite the separator character + 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: event.ignore()