Open 10110111 opened 8 years ago
Yea, I remember these from when I first implemented this dialog. It proved to be very tricky to get right with Qt validators. I think the only way to get the "perfect" behavior is essentially do as you suggest and have the widget separate data from presentation. Internally, it should just know about hex digits, but then when it displays, at that point it would choose to display the spaces strictly as visual spacers.
To reproduce:
This naturally occurs when you e.g. delete bytes in the middle of the string instead of the end.
Interestingly, if I do the opposite — i.e. press Delete when the cursor is before space, the cursor is moved forward. Although it doesn't actually delete anything, I can at least press Delete once again and get the char deleted.
Ideally, the spaces there should be nothing more than spacers, i.e. something invisible to keyboard navigation & editing process. Namely, pressing Delete before space should place the cursor after that space and delete char forward, and pressing Backspace after space should place the cursor before that space and delete the char backward.