Skip to content

Make disabled state valid and complete across all interactive widgets - #631

Open
metif12 wants to merge 1 commit into
vlang:masterfrom
metif12:disabled-all-widgets
Open

metif12 wants to merge 1 commit into
vlang:masterfrom
metif12:disabled-all-widgets

Conversation

@metif12

@metif12 metif12 commented Nov 21, 2026

Copy link
Copy Markdown
Member

Problem

disabled was only partially implemented. An audit of every interactive widget found:

  • CheckBox.disabled was declared, set in the constructor and documented in docs.md ("Disable interaction"), but never read — a disabled checkbox still toggled by mouse and by Enter/Space.
  • ListBox disabled items could still be selected by single-select mouse clicks and Up/Down keys, dragged, and hover-highlighted; is_item_selected disagreed between multi- and single-select mode.
  • The focus subsystem (Focusable.has_focusable, set_focus, force_focus) never checked disabled, so disabled widgets were Tab-reachable and could steal focus.
  • Every other interactive widget (Dropdown, Switch, Radio, Slider, TextBox, Picture, Menu/MenuItem) had no disabled state at all.
  • Button (see Add disabled check to btn_key_down() in button.v #629) is the only widget whose disabled state was already usable.

Changes

  • Add a disabled field + disabled param + dimmed drawing to Dropdown, Switch, Radio, Slider, TextBox, Picture, Menu and MenuItem.
  • Guard every input handler (click, key down, mouse down/up/move, touch move, hover cursor) with the disabled check; Slider's change_value is guarded centrally as well.
  • Make CheckBox.disabled actually block mouse and keyboard toggling.
  • Fix ListBox disabled items: single-select clicks now reject them, arrow navigation skips them (without firing a spurious on_change), dragging and hover highlighting ignore them, and is_item_selected* is consistent.
  • Add Focusable.is_disabled(); focus navigation, set_focus() and force_focus() now skip disabled widgets instead of focusing them.
  • Add a shared dim_color() helper and document all new params in docs.md.

Scope and verification notes

  • Native widgets mode is intentionally out of scope: no native create/update API carries disabled/hidden on any platform, and native_button_set_enabled / Win32 EnableWindow / ShowWindow are declared but never called. That needs a separate cross-platform change.
  • No overlap with Add disabled check to btn_key_down() in button.v #629: this PR does not touch button.v.
  • All changed V files parse cleanly with v fmt. A full type-check build is blocked by pre-existing master errors under V 0.5.2 (dropdown.v:103 immutable parent, layout_canvas.v shadowing/immutability, deprecated usize/isize, and a C.DestroyWindow signature conflict). The same errors occur on unmodified master; a patched baseline build showed no new errors from this change. CI on master is already red for lint/fmt and setup.

Add a disabled field and param to Dropdown, Switch, Radio, Slider, TextBox, Picture and Menu/MenuItem, and guard every input handler so disabled widgets cannot be clicked, focused, dragged or typed into. Dim their drawing with a shared dim_color helper.

CheckBox.disabled was declared but never read; it now blocks both mouse and keyboard toggling. ListBox disabled items are no longer selectable via single-select clicks or arrow keys, draggable, or hover-highlighted. Focus navigation now skips disabled widgets via Focusable.is_disabled(), and set_focus/force_focus no longer steal focus for them.

Document the new params in docs.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant