I’d like to build a view similar to the following, a hex viewer where I can display hex bytes, with ability to choose different background colors for each byte, and also possibly be able to click on a byte and change the value:
I’ve tried to add monospaced text widgets to a row, and stack the rows in a column. This works but I end up with lots of different widgets, and the text widgets are not editable.
I suppose I can try using TextInput widgets but I have one for each byte, there’s still many, and if I have one per row or one for the whole screen, it’s possible for the user to create invalid hex views.
All these methods also don’t work if I do not use monospaced fonts because columns of bytes will not align.
I would start with the one-input-per-cell approach and go from there. Maybe try to separate the logic from presentation as much as possible, so in the future you could swap everything with another widget or even a custom one.
maybe consider using Canvas. you could hold an Interaction enum in your widget state that switches from Interaction::Idle to Interaction::Editing and handles key presses accordingly. you’ll need to create some sort of Cursor struct too and keep track of its current position
check out the game_of_life example which demonstrates how to make a grid on a Canvas (and includes many things you don’t need)
a more advanced approach might be to rewrite the built-intext_editor widget to suit the specific needs of your application, but that’s advanced stuff so I would only start there if you’re already an experienced programmer and happy to figure out a lot of complex code on your own
either way, it’s not exactly a simple task, but that complexity is inherent to your needs, so you can’t really avoid it
P.S. for what it’s worth, I think you should use monospace fonts exclusively, because this kind of UI is exactly why such fonts exist…