-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'disabled' state to widgets. #746
Comments
Hey just bumping this because I'm dealing with it for a Button right now in my own app. There seem like so many different ways to deal with this I don't really know the right approach, but here's what I'm leaning toward for my own project: Setting a canonical "DISABLED" key in the Env makes it easy to visually respond to the disabled state. It's also easy to do wrap a whole section of the tree in a env_scope and disabled it all at once. The on_click handler in Button can also check the Env and just do nothing when "DISABLED" is true. More complicated interactions maybe need more bespoke handling of what DISABLED means to them. Could set this key directly with .env_scope(|env, data| {
env.set(DISABLED, data.should_be_disabled);
}); Or have some sort of convenience method in WidgetExt: .set_disabled(|data| data.should_be_disabled); This is all about ignoring events at the leaf, does nothing to address not sending them down, so I don't know if this is an ideal solution but it seems reasonable to me. |
Flutter uses "null" to indicate disabled for things like text boxes. |
The big question to me is whether this should be something that is set in the I do think there might be some problems with putting it in In any case I do think this should be added, and should be used in built-in widgets. |
I'm not sure if it would be enough to set a flag in
Maybe the |
I agree that the env is not enough for this; 'disabled' is a special state that needs to be known to the framework. |
I would like to try to implement this, if no one is already doing it. |
@xarvic you're welcome to play around, but there are some deep questions involved, like exactly how disabled widgets should participate in event delivery; do we stop delivering all events, and then begin again later? In this case we may want to add 'Disabled/Enabled' lifecycle events, and I haven't thought through all of the possible consequences of this.. |
This is a way to communicate to control widgets that they should not respond to user input, and that they should paint themselves as 'disabled'. The 'not responding' bit might even be handled in the
WidgetPod
; it could just not send certain events on to the widget when this is set?We may also want lifecycle events for
DisabledChanged
? That's sort of funky because it is missing concerns a little bit. This probably needs a bit more thought.The text was updated successfully, but these errors were encountered: