Interface UITextSearching

  • All Known Implementing Classes:
    UITextView

    public interface UITextSearching
    API-Since: 16.0
    • Method Detail

      • clearAllDecoratedFoundText

        void clearAllDecoratedFoundText()
        Called when the current search session has changed or ended, with the expectation that all decorations applied via @c decorateFoundTextRange:usingStyle: are cleared.
      • compareFoundRangeToRangeInDocument

        long compareFoundRangeToRangeInDocument​(@NotNull
                                                @NotNull UITextRange foundRange,
                                                @NotNull
                                                @NotNull UITextRange toRange,
                                                @Nullable
                                                @Nullable java.lang.Object document)
        Provide a comparison result comparing developer-provided @c fromRange to @c toRange . This is used by the system find panel to know which @c UITextRange to highlight next when the user taps the "next" or "previous" result buttons.
        Parameters:
        foundRange - Developer-provided range to compare from.
        toRange - Developer-provided range to compare to.
        document - If multiple documents are used, a document identifier will be provided here. Ranges are only compared between other ranges of the same document.
      • compareOrderFromDocumentToDocument

        default long compareOrderFromDocumentToDocument​(@NotNull
                                                        @NotNull java.lang.Object fromDocument,
                                                        @NotNull
                                                        @NotNull java.lang.Object toDocument)
        Returns the visible ordering from `fromDocument` to `toDocument`. If your document identifiers are index paths, for example, this would yield the same result as `-[NSIndexPath compare:]`.
      • decorateFoundTextRangeInDocumentUsingStyle

        void decorateFoundTextRangeInDocumentUsingStyle​(@NotNull
                                                        @NotNull UITextRange range,
                                                        @Nullable
                                                        @Nullable java.lang.Object document,
                                                        long style)
        Given a found @c range , decorate this text appropriately using the provided @c style type.
        Parameters:
        range - The range of text to decorate.
        document - If multiple documents are used, the relevant document identifier is provided here. Otherwise nil.
        style - A style hint for how to decorate the text. This is ultimately up to the developer, but developers are encouraged to match the system's appearance (i.e., UITextView) as close as possible.
      • performTextSearchWithQueryStringUsingOptionsResultAggregator

        void performTextSearchWithQueryStringUsingOptionsResultAggregator​(@NotNull
                                                                          @NotNull java.lang.String string,
                                                                          @NotNull
                                                                          @NotNull UITextSearchOptions options,
                                                                          @NotNull
                                                                          @NotNull UITextSearchAggregator aggregator)
        Perform a text search (across all available searchable documents) using @c string. When results are found, provide the results to @c aggregator.
        Parameters:
        string - The query string to search for
        options - Search options provided by the user.
        aggregator - When results are found, provide them to the aggregator. The aggregator is thread-safe, so you may send it messages on other threads.
      • replaceAllOccurrencesOfQueryStringUsingOptionsWithText

        default void replaceAllOccurrencesOfQueryStringUsingOptionsWithText​(@NotNull
                                                                            @NotNull java.lang.String queryString,
                                                                            @NotNull
                                                                            @NotNull UITextSearchOptions options,
                                                                            @NotNull
                                                                            @NotNull java.lang.String replacementText)
        When replacing all occurrences at once, this method is called instead of the one above.
        Parameters:
        queryString - The search term to replace.
        options - Search options provided by the find panel UI.
        replacementText - The string to replace it with.
      • replaceFoundTextInRangeInDocumentWithText

        default void replaceFoundTextInRangeInDocumentWithText​(@NotNull
                                                               @NotNull UITextRange range,
                                                               @Nullable
                                                               @Nullable java.lang.Object document,
                                                               @NotNull
                                                               @NotNull java.lang.String replacementText)
        If you return YES for `-supportsTextReplacement`, this method will be called whenever the user intends to replace a range of text.
        Parameters:
        range - The range of text requesting to be replaced.
        document - If multiple search documents are used, the relevant document identifier is provided here. Otherwise nil.
        replacementText - The replacement string.
      • scrollRangeToVisibleInDocument

        default void scrollRangeToVisibleInDocument​(@NotNull
                                                    @NotNull UITextRange range,
                                                    @Nullable
                                                    @Nullable java.lang.Object document)
        If scrolling is supported, implement this to know when the document should be scrolled to a particular search result.
        Parameters:
        range - The text range to scroll to.
        document - (Optional) If multiple documents are used, the document identifier to scroll to.
      • selectedTextRange

        @Nullable
        @Nullable UITextRange selectedTextRange()
        Overlap from UITextInput: Returns the currently selected text range, if applicable. Nil otherwise.
      • selectedTextSearchDocument

        @Nullable
        default @Nullable java.lang.Object selectedTextSearchDocument()
        Returns the current search document, if applicable. Nil otherwise.
      • shouldReplaceFoundTextInRangeInDocumentWithText

        default boolean shouldReplaceFoundTextInRangeInDocumentWithText​(@NotNull
                                                                        @NotNull UITextRange range,
                                                                        @Nullable
                                                                        @Nullable java.lang.Object document,
                                                                        @NotNull
                                                                        @NotNull java.lang.String replacementText)
        Optionally return NO to disallow the replacement of a particular result @c range . This will disable the "replace" button in the UI. If this method is unimplemented, it is assumed that all results are replaceable.
        Parameters:
        range - Range to replace.
        document - If multiple documents are used, the document from which range originates.
        replacementText - Text that the user intends to replace with.
      • supportsTextReplacement

        default boolean supportsTextReplacement()
        Return YES if your searchable item also supports replacement. If this method is unimplemented, it is assumed that text replacement is not supported.
      • willHighlightFoundTextRangeInDocument

        default void willHighlightFoundTextRangeInDocument​(@NotNull
                                                           @NotNull UITextRange range,
                                                           @Nullable
                                                           @Nullable java.lang.Object document)
        Called when the highlighted search result is about to change to @c range .