cocoa: reconcile NativeControl descriptors (Surface provider or widget tree) - #88
Merged
Conversation
…t tree) Reworks syncNative onto go-widgets/toolkit's NativeControl descriptor (toolkit v0.299.0). The backend gathers this frame's controls from the root's own provider when it has one — a self-rendering toolkit.Surface, which is how the news reader is built — else by walking it as a widget tree, and reconciles the same descriptors either way, holding one real AppKit control per Key across frames. The value binding is immediate-mode-safe by construction: a descriptor's value is pushed into a control only when it differs from what the control last reported. When the person edits, the change flows out through the descriptor's callback and the app's next descriptor carries that same value — equal, so nothing is pushed back and the caret is never disturbed. Only a value the app changed on its own is pushed. This replaces the observable-subscription binding of #86, which could not serve a Surface app and pushed on every observable set rather than per frame. Proven on-device by two gated live tests (WINDOW_COCOA_INTEGRATION): the widget-tree path and the Surface-provider path — the reader's actual mechanism — each embedding a real NSSecureTextField, round-tripping its value, and pushing an app-side change into the field. Requires go-widgets/toolkit v0.299.0 and go-macos/appkit v0.1.0.
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.
Reworks the cocoa native-control backend from #86 onto go-widgets/toolkit's new NativeControl descriptor (toolkit v0.299.0), so it serves both an ordinary widget tree and a self-rendering `toolkit.Surface` — which is how the news reader is built (its Surface has no walkable widget tree, so `WalkNative` alone could not reach its controls).
What changes
Proof
Two gated live tests (`WINDOW_COCOA_INTEGRATION`, run on-device): the widget-tree path and the Surface-provider path (the reader's mechanism), each embedding a real `NSSecureTextField`, round-tripping its value, and pushing an app-side change into the field. The `gatherNative` provider-vs-walk selection is unit-tested in CI.
Deps
Requires `go-widgets/toolkit` v0.299.0 and `go-macos/appkit` v0.1.0.