Repository navigation
Tell the app when the selection changes - #18
Merged
Merged
Conversation
An app could set the selection with select(_:) and read selectedText, but it could not find out when the person changed or ended a selection. TranscriptTextView now has selectedRange and onSelectionChange, which is called on the main thread after each change, with nil when nothing is selected any more. selectsAllWhenShown selects all of the text, with the selection handles shown, once the view is in a window and has text. TranscriptText has .onSelectionChange(_:) and .selectsAllWhenShown(_:). Closes #6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 20, 2026
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.
Summary
An app could set the selection with
select(_:)and readselectedText, but it could not find out when the person changed or ended a selection.TranscriptTextView.selectedRange: the selection in the document's flat UTF-16 offset space, or nil.TranscriptTextView.onSelectionChange: called on the main thread after each change, with nil when nothing is selected any more.TranscriptTextView.selectsAllWhenShown: selects all of the text, with the selection handles shown, once the view is in a window and has text.TranscriptTexthas.onSelectionChange(_:)and.selectsAllWhenShown(_:).Closes #6.
Stack
This PR is part of a stack. It is based on #17 (
feature/turn-off-selection), so its diff shows only this change. Merge the stack in order, starting with #17.Tests
swift testpasses with it in the stack..selectsAllWhenShown(), the view became first responder withselectedRange0..<48and the whole text inselectedText.select(nil)cleared it, andonSelectionChangereported0..<48, thennil.🤖 Generated with Claude Code