NSTextFinderClient Protocol Reference
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.7 and later. |
| Declared in | NSTextFinder.h |
Overview
The NSTextFinderClient protocol is implemented by objects that wish to support searching using the NSTextFinder class and the in-window text finder bar.
See NSTextFinder Class Reference for details.
Tasks
String Searching
Replacing Text
-
– shouldReplaceCharactersInRanges:withStrings: -
– replaceCharactersInRange:withString: -
– didReplaceCharacters
Selection Information
-
selectablerequired property -
allowsMultipleSelectionproperty -
firstSelectedRangeproperty -
selectedRangesproperty
Text Edibility
-
editableproperty
Determining and Displaying Text Locations
-
– contentViewAtIndex:effectiveCharacterRange: -
– rectsForCharacterRange: -
– scrollRangeToVisible: -
visibleCharacterRangesproperty
Drawing Glyphs
-
– drawCharactersInRange:forContentView:required method
Properties
allowsMultipleSelection
Returns whether multiple items can be selected. (read-only)
Discussion
If this properties is not implemented, the text finder will act as if they returned YES.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.heditable
Returns whether the text is editable. (read-only)
Discussion
The text finder uses this property to validate actions. If is it not implemented, the value is assumed to be YES .
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hfirstSelectedRange
Returns the currently selected range. (read-only)
Discussion
This property is required for the next match, previous match, replace, replace and find and set search string actions.. The client should return its first selected range, or {index, 0} to indicate the location of the insertion point if there is no selection.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hselectable
Returns whether the text is selectable. (required) (read-only)
Discussion
If this properties is not implemented, the text finder will act as if they returned YES.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hselectedRanges
Returns an array of selected ranges.
Discussion
This property is required for the replace all in selection, select all, and select all in selection actions. The returned NSArray object should contain NSRanges wrapped by NSValues.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hstring
Allows the client to specify a single string for searching. (read-only)
Discussion
If the client cannot logically or efficiently flatten itself into a single string, then the stringAtIndex:effectiveRange:endsWithSearchBoundary: and stringLength methods should be implemented instead.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hvisibleCharacterRanges
An array of visible character ranges. (read-only)
Discussion
The text finder uses this property's value to determine which ranges it should search to show all of the incremental matches that are currently visible.
If this property is not implemented, then the incremental matches cannot be shown.
The array contains NSValue objects that wrap NSRect structures.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hInstance Methods
contentViewAtIndex:effectiveCharacterRange:
Returns the view the context is displayed in.
Parameters
- index
The index of the view containing the located text.
- outRange
Returns, by reference, the entire range of the string displayed by the view
Return Value
Returns the view the contains the found text.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hdidReplaceCharacters
Specifies whether text characters were replaced.
Discussion
See NSTextFinder Class Reference for a complete description.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hdrawCharactersInRange:forContentView:
Draw the glyphs for the requested character range as they are drawn in the given content view. (required)
Parameters
- range
The character range.
- view
The content view.
Discussion
If the character range partially intersects a glyph range, then the full glyph is drawn to avoid additional layout.
The given range is guaranteed to be completely contained by the given view. When this method is called, a drawing context effectively identical to the one provided to the view’s drawRect: method is configured. This method is mainly used to draw find indicator contents, so implementations should check -the view property isDrawingFindIndicator to ensure that the text will be easily readable against the background of the find indicator when it returns YES. If this method is not implemented, then the find indicator will be drawn using the content view’s drawRect: method instead.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hrectsForCharacterRange:
An array containing the located text in the content view’s coordinate system.
Parameters
- range
The range of the located character string.
Return Value
An array containing the rectangles containing the located text in the content view object’s coordinate system and return that array. The rectangles are return wrapped as NSValue objects.
Discussion
The text finder uses this method to determine the location to display the find indicator.
The given range is guaranteed not to overlap multiple views.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hreplaceCharactersInRange:withString:
Replaces the text in the specified range with the new string.
Parameters
- range
The specified range of the text to replace.
- string
The replacement string.
Discussion
See NSTextFinder Class Reference for a complete description.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hscrollRangeToVisible:
Scrolls the specified range such that it is visible.
Parameters
- range
The range to display.
Discussion
This method is used by all actions, but is not strictly required by any.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hshouldReplaceCharactersInRanges:withStrings:
Returns whether the specified strings should be replaced.
Parameters
- ranges
The ranges of the strings to replace.
- strings
The replacement strings.
Return Value
Returns YES if the replacement should occur; otherwise NO.
Discussion
See NSTextFinder Class Reference for a complete description.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hstringAtIndex:effectiveRange:endsWithSearchBoundary:
Returns the found string that is created by conceptually mapping its content to a single string, which is composed of a concatenation of all its substrings.
Parameters
- characterIndex
The given character index the client should return.
- outRange
Returns, by reference, the "effective range" of that substring in the full conceptually concatenated string
- outFlag
Returns, by-reference, whether the substring ends with a "search boundary", meaning that NSTextFinder should not attempt to find any matches that overlap this boundary.
Return Value
Returns the found string.
Discussion
See NSTextFinder Class Reference for more information.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.hstringLength
Returns the full length of the conceptually concatenated string return by the stringAtIndex:effectiveRange:endsWithSearchBoundary: method.
Return Value
Returns the full length of the conceptually concatenated string in the second model, that is, the sum of the lengths of all of its substrings.
Discussion
See NSTextFinder Class Reference for more information.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextFinder.h© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-06-06)