Open dhardy opened 2 years ago
Important to the above is a question: what is the purpose of the disabled state anyway? I can imagine two related cases:
ScrollLabel
, while EditBox
and CheckBox
have an editable
property.This prompts some questions:
editable
a property of a few widgets while disabled
is a property of all widgets? Well, only a few widgets appear to be both interactive by design and useful while read-only, while most widgets (potentially even labels) may be affected by the disabled
property in some way. (Only a partial rationale.)disabled
state be set recursively but read-only
cannot? Again, a half-answer: it may be necessary to disable many widgets, but it's not usually necessary to set many to read-only mode.Thus, we could possibly make this change:
read-only
a property of the EventState
not the widget, like disabled
currently is, except that widget event handlers must implement behaviour adjustments themselves
Follows: #82
What actions are/should be possible for disabled widgets?
Before #323, no events were sent to disabled widgets; since then
Event::pass_when_disabled
is used to determine whether the event should be sent to disabled widgets (roughly speaking, input events are not sent while programmatic updates are).Active pointer/character/selection grabs cancelled— it's not clear that this is necessary;Lost*Focus
events are still sent to disabled widgetsPressEnd
if widget is disabled during a grab? Currently it's not.Due to the last point, it isn't clear that "do not send events" is the best way to implement disabled status.
Further note: the Gallery example now has its own
trait SetDisabled: Widget
used to disable panels inside aTabStack
widget. This feels a little wrong.Alternative: widgets implement their own disabled behaviour
This is a possibility, but probably not the right one (it results in a lot of boring, repetitive code that often won't be well tested):
fn set_disabled(bool)
toWidget
(which doesn't necessarily need to do anything, since disabled status can already be queried via theEventState
)A variant of this: