You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building my 7 Humble GUIs project, I ended up copying and modifying the text-field component to accept an on-change event handler in addition to the atom that would track the state, so that I could change other parts of a form when the user was typing into the input and ignore updates to the state that were caused by other things.
What do you think of adopting this for the text-input/text-field and other stateful widgets?
Moving to a more event-oriented system could also allow for more customization of behavior. For example, if a user wanted to disallow anything but numbers entered into a text-field, they would again have to fork the widget and write that logic. If instead, the widget didn't mutate the atom when typing if an on-change handler was passed in, a user could encode this logic easily themselves:
Yes, on-change would be a great addition. I’m still not sure what to do with local state (rest of the stuff that text-input stores in the atom), but that’s another story. For now I can merge on-change if you make a PR
When building my 7 Humble GUIs project, I ended up copying and modifying the text-field component to accept an
on-change
event handler in addition to the atom that would track the state, so that I could change other parts of a form when the user was typing into the input and ignore updates to the state that were caused by other things.This made the code for the temperature converter quite simple to write:
https://github.com/lilactown/7-humble-guis/blob/a69a600a11373ca0dffe18ec5da887ee4120d45a/src/town/lilac/humble/app/gui_2.clj#L66-L84
What do you think of adopting this for the text-input/text-field and other stateful widgets?
Moving to a more event-oriented system could also allow for more customization of behavior. For example, if a user wanted to disallow anything but numbers entered into a text-field, they would again have to fork the widget and write that logic. If instead, the widget didn't mutate the atom when typing if an
on-change
handler was passed in, a user could encode this logic easily themselves:The text was updated successfully, but these errors were encountered: