kas-gui / kas

Another GUI toolkit
Apache License 2.0
901 stars 25 forks source link

Disabled state: details #328

Open dhardy opened 2 years ago

dhardy commented 2 years ago

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).

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 a TabStack 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):

A variant of this:

dhardy commented 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:

  1. The widget is used for output only and not interactive. For this purpose, we have the dedicated read-only ScrollLabel, while EditBox and CheckBox have an editable property.
  2. The widget is part of the UI design but not currently applicable (e.g. the "return date" when booking a one-way flight). For this purpose, the widget can be disabled, both preventing editing and visually de-focussing (but not completely hiding) the widget.

This prompts some questions:

Thus, we could possibly make this change: