Add ability to save, edit and load custom practice states#348
Add ability to save, edit and load custom practice states#348LukeSaward wants to merge 5 commits intomasterfrom
Conversation
oberien
left a comment
There was a problem hiding this comment.
To have the parsing in the UI element itself, the UI element needs a way to display error messages. In general we seem to be using the pattern quite a lot where we modify the label of an input when parsing the value either onchange or onclick. It might make sense to add that as option to the existing or as new UI-Elements to reduce lots of boilerplate in the future.
I see 3 different ways to achieve this:
- Have the event functions return a string which is added to the label.
- Pass the label to the function and have the label have its own suffix field and function, which gets reset before calling the event function and concatenated afterwards.
- The UI Element could store the old value and reset it every change.
The latter may be the cleanest as it doesn't require a Label to be { text: string, suffix: string }, which might not make much sense. Though it also feels a lot like magic and be unintuitive if the UI Element automatically resets the label all the time.
That change could also be done in a different PR as this one is already quite large.
d7856e3 to
cc383dd
Compare
a1b965a to
6a2ff73
Compare
b619db4 to
5405951
Compare
| if key.to_small() == KEY_BACKSPACE.to_small() { | ||
| self.input = self.input.slice(0, -1); | ||
| } else if key.to_small() == KEY_V.to_small() && (LCTRL_PRESSED || RCTRL_PRESSED) { | ||
| self.input = f"{self.input}{Tas::get_clipboard()}"; |
There was a problem hiding this comment.
You never check if the clipboard is valid. This way the user could paste non-number characters and Refunct will crash the next time onclick is called.
| Option::None => (), | ||
| } | ||
| } | ||
| match character.parse_int() { |
There was a problem hiding this comment.
This should probably use is_digit.
5405951 to
5ef784e
Compare
Resolves #122