Refactor: a disabled wrapper alone blocks choice bases
TestBasesBlockedByDisabledWrapper focuses CheckboxBase, RadioBase, SwitchBase and ToggleBase, flips their wrapper to Disabled and presses Space: none changes its value, and each does without the flip. So choiceTarget goes from Switch, Toggle and MultiSelect, and PopupMenu Check drops its copy; TestChoiceDisabledWhileFocused and TestDropdownMenuCheckDisabledThisFrameKeepsValue still pass. ComboboxBase is different: TestComboboxBaseIgnoresDisabledWrapper shows a focused one still takes typing under a disabled wrapper, so Combobox keeps a copy, now inline as its only user.
This commit is contained in:
6 files changed
+70
-22
No files matched your search
+2
-7
@@ -56,14 +56,9 @@ func (m *PopupMenu) Item(label string, opts PopupMenuItemOptions) bool {
|
||||
|
||||
// Check adds an item toggling *checked and reports whether it changed.
|
||||
func (m *PopupMenu) Check(label string, checked *bool, opts PopupMenuItemOptions) bool {
|
||||
// The base toggles as it is built, so a disabled wrapper and a copy come first.
|
||||
value := checked
|
||||
if opts.Disabled {
|
||||
cp := *checked
|
||||
value = &cp
|
||||
}
|
||||
// The base toggles as it is built, so a disabled wrapper comes first.
|
||||
var base *ui.Element
|
||||
ui.Column(m.c).Shrink(0).Disabled(opts.Disabled).Children(func() { base = ui.CheckboxBase(m.c, value) })
|
||||
ui.Column(m.c).Shrink(0).Disabled(opts.Disabled).Children(func() { base = ui.CheckboxBase(m.c, checked) })
|
||||
it := m.row(base, opts.Disabled, false)
|
||||
m.content(it, label, *checked, false)
|
||||
if opts.Disabled || !it.Changed() {
|
||||
|
||||
Reference in new issue
Block a user