Repository navigation
Conversation
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.
Native widgets mode never received the V model's disabled/hidden flags. Add set_enabled/set_visible to the Windows, macOS and default backends plus a shared NativeWidgets.sync_state helper, and call it from each widget's native init, native draw path and set_visible(). A disabled native button no longer fires on_click. Windows uses EnableWindow/ShowWindow; macOS sends setEnabled:/setHidden: to the control; the default backend is a no-op as before. Per-item ListBox.disabled is not representable in native list controls and is left to the custom rendering path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Native widgets mode never received the V model's
disabled/hiddenflags:native_button_set_enabled(macOS) and Win32EnableWindow/ShowWindow/IsWindowVisiblewere declared but never called;on_clickthroughnative_button_clicked;Change
NativeWidgets.set_enabled()/set_visible()on all three backends and a sharednative_widgets.sync_state()helper.EnableWindow+ShowWindow(sw_show/sw_hide, both already declared).setEnabled:andsetHidden:via the existingmacos_objc_msg_void_boolhelper.sync_state()from every native widget'sinit(), from its native draw path, and fromset_visible()(hidden widgets are filtered out ofdrawing_children, so draw alone cannot hide them).native_button_clicked()withhidden || disabled.ListItem.disabledis per-item and cannot be expressed in native list controls; it stays on the custom rendering path.Notes
disabledfields for widgets other than Button, whose fix is already merged via Add disabled check to btn_key_down() in button.v #629). Once Make disabled state valid and complete across all interactive widgets #631 merges, this PR's diff shrinks to commit97b75ad(16 files, +121).v fmt; a patched type-check build on Windows shows no new errors versus unmodifiedmaster. The macOS backend could not be compiled on this host, so it has been kept to the two Objective-C message calls already used elsewhere in that file.