20 @property(nonatomic, copy) NSString*
text;
26 @synthesize beginningOfDocument = _beginningOfDocument;
27 @synthesize endOfDocument = _endOfDocument;
32 @synthesize tokenizer = _tokenizer;
35 return self.text.length > 0;
38 - (NSString*)textInRange:(UITextRange*)range {
43 @"Expected a FlutterTextRange for range (got %@).", [range
class]);
45 if (textRange.location == NSNotFound) {
53 return [
self.text substringWithRange:textRange];
56 - (void)replaceRange:(UITextRange*)range withText:(NSString*)
text {
62 - (void)setMarkedText:(NSString*)markedText selectedRange:(NSRange)markedSelectedRange {
74 - (UITextRange*)textRangeFromPosition:(UITextPosition*)fromPosition
75 toPosition:(UITextPosition*)toPosition {
81 - (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
88 - (UITextPosition*)positionFromPosition:(UITextPosition*)position
89 inDirection:(UITextLayoutDirection)direction
90 offset:(NSInteger)offset {
97 - (NSComparisonResult)comparePosition:(UITextPosition*)position toPosition:(UITextPosition*)other {
101 return NSOrderedSame;
104 - (NSInteger)offsetFromPosition:(UITextPosition*)from toPosition:(UITextPosition*)toPosition {
111 - (UITextPosition*)positionWithinRange:(UITextRange*)range
112 farthestInDirection:(UITextLayoutDirection)direction {
119 - (UITextRange*)characterRangeByExtendingPosition:(UITextPosition*)position
120 inDirection:(UITextLayoutDirection)direction {
127 - (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition*)position
128 inDirection:(UITextStorageDirection)direction {
130 return UITextWritingDirectionNatural;
133 - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection
134 forRange:(UITextRange*)range {
138 - (CGRect)firstRectForRange:(UITextRange*)range {
152 - (UITextPosition*)closestPositionToPoint:(CGPoint)point {
159 - (UITextPosition*)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange*)range {
166 - (NSArray*)selectionRectsForRange:(UITextRange*)range {
173 - (UITextRange*)characterRangeAtPoint:(CGPoint)point {
180 - (void)insertText:(NSString*)
text {
186 - (void)deleteBackward {
198 - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge
200 self = [
super initWithBridge:bridge uid:uid];
209 #pragma mark - SemanticsObject overrides
211 - (void)setSemanticsNode:(
const flutter::SemanticsNode*)node {
212 [
super setSemanticsNode:node];
213 _inactive_text_input.
text = @(node->value.data());
219 if ([
self node].flags.isFocused == flutter::SemanticsTristate::kTrue) {
220 textInput.backingTextInputAccessibilityObject =
self;
223 textInput.frame = CGRectMake(0.0, 0.0, 1.0, 1.0);
224 }
else if (textInput.backingTextInputAccessibilityObject ==
self) {
225 textInput.backingTextInputAccessibilityObject = nil;
229 #pragma mark - UIAccessibility overrides
239 - (UIView<UITextInput>*)textInputSurrogate {
241 if (bridge && [
self node].flags.isFocused == flutter::SemanticsTristate::kTrue) {
244 return _inactive_text_input;
248 - (UIView*)textInputView {
249 return [
self textInputSurrogate];
252 - (void)accessibilityElementDidBecomeFocused {
256 [[
self textInputSurrogate] accessibilityElementDidBecomeFocused];
257 [
super accessibilityElementDidBecomeFocused];
260 - (void)accessibilityElementDidLoseFocus {
264 [[
self textInputSurrogate] accessibilityElementDidLoseFocus];
265 [
super accessibilityElementDidLoseFocus];
268 - (BOOL)accessibilityElementIsFocused {
272 return [
self node].flags.isFocused == flutter::SemanticsTristate::kTrue;
275 - (BOOL)accessibilityActivate {
279 return [[
self textInputSurrogate] accessibilityActivate];
282 - (NSString*)accessibilityLabel {
287 NSString* label = [
super accessibilityLabel];
291 return [
self textInputSurrogate].accessibilityLabel;
294 - (NSString*)accessibilityHint {
298 NSString* hint = [
super accessibilityHint];
302 return [
self textInputSurrogate].accessibilityHint;
305 - (NSString*)accessibilityValue {
309 NSString* value = [
super accessibilityValue];
313 return [
self textInputSurrogate].accessibilityValue;
316 - (UIAccessibilityTraits)accessibilityTraits {
320 UIAccessibilityTraits results =
321 [
super accessibilityTraits] | [
self textInputSurrogate].accessibilityTraits;
328 #pragma mark - UITextInput overrides
330 - (NSString*)textInRange:(UITextRange*)range {
331 return [[
self textInputSurrogate] textInRange:range];
334 - (void)replaceRange:(UITextRange*)range withText:(NSString*)
text {
335 return [[
self textInputSurrogate] replaceRange:range withText:text];
338 - (BOOL)shouldChangeTextInRange:(UITextRange*)range replacementText:(NSString*)
text {
339 return [[
self textInputSurrogate] shouldChangeTextInRange:range replacementText:text];
343 return [[
self textInputSurrogate] selectedTextRange];
346 - (void)setSelectedTextRange:(UITextRange*)range {
347 [[
self textInputSurrogate] setSelectedTextRange:range];
351 return [[
self textInputSurrogate] markedTextRange];
355 return [[
self textInputSurrogate] markedTextStyle];
358 - (void)setMarkedTextStyle:(NSDictionary*)style {
359 [[
self textInputSurrogate] setMarkedTextStyle:style];
362 - (void)setMarkedText:(NSString*)markedText selectedRange:(NSRange)selectedRange {
363 [[
self textInputSurrogate] setMarkedText:markedText selectedRange:selectedRange];
367 [[
self textInputSurrogate] unmarkText];
370 - (UITextStorageDirection)selectionAffinity {
371 return [[
self textInputSurrogate] selectionAffinity];
374 - (UITextPosition*)beginningOfDocument {
375 return [[
self textInputSurrogate] beginningOfDocument];
378 - (UITextPosition*)endOfDocument {
379 return [[
self textInputSurrogate] endOfDocument];
383 return [[
self textInputSurrogate] inputDelegate];
386 - (void)setInputDelegate:(id<UITextInputDelegate>)delegate {
387 [[
self textInputSurrogate] setInputDelegate:delegate];
390 - (id<UITextInputTokenizer>)tokenizer {
391 return [[
self textInputSurrogate] tokenizer];
394 - (UITextRange*)textRangeFromPosition:(UITextPosition*)fromPosition
395 toPosition:(UITextPosition*)toPosition {
396 return [[
self textInputSurrogate] textRangeFromPosition:fromPosition toPosition:toPosition];
399 - (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
400 return [[
self textInputSurrogate] positionFromPosition:position offset:offset];
403 - (UITextPosition*)positionFromPosition:(UITextPosition*)position
404 inDirection:(UITextLayoutDirection)direction
405 offset:(NSInteger)offset {
406 return [[
self textInputSurrogate] positionFromPosition:position
407 inDirection:direction
411 - (NSComparisonResult)comparePosition:(UITextPosition*)position toPosition:(UITextPosition*)other {
412 return [[
self textInputSurrogate] comparePosition:position toPosition:other];
415 - (NSInteger)offsetFromPosition:(UITextPosition*)from toPosition:(UITextPosition*)toPosition {
416 return [[
self textInputSurrogate] offsetFromPosition:from toPosition:toPosition];
419 - (UITextPosition*)positionWithinRange:(UITextRange*)range
420 farthestInDirection:(UITextLayoutDirection)direction {
421 return [[
self textInputSurrogate] positionWithinRange:range farthestInDirection:direction];
424 - (UITextRange*)characterRangeByExtendingPosition:(UITextPosition*)position
425 inDirection:(UITextLayoutDirection)direction {
426 return [[
self textInputSurrogate] characterRangeByExtendingPosition:position
427 inDirection:direction];
430 - (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition*)position
431 inDirection:(UITextStorageDirection)direction {
432 return [[
self textInputSurrogate] baseWritingDirectionForPosition:position inDirection:direction];
435 - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection
436 forRange:(UITextRange*)range {
437 [[
self textInputSurrogate] setBaseWritingDirection:writingDirection forRange:range];
440 - (CGRect)firstRectForRange:(UITextRange*)range {
441 return [[
self textInputSurrogate] firstRectForRange:range];
445 return [[
self textInputSurrogate] caretRectForPosition:position];
448 - (UITextPosition*)closestPositionToPoint:(CGPoint)point {
449 return [[
self textInputSurrogate] closestPositionToPoint:point];
452 - (UITextPosition*)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange*)range {
453 return [[
self textInputSurrogate] closestPositionToPoint:point withinRange:range];
456 - (NSArray*)selectionRectsForRange:(UITextRange*)range {
457 return [[
self textInputSurrogate] selectionRectsForRange:range];
460 - (UITextRange*)characterRangeAtPoint:(CGPoint)point {
461 return [[
self textInputSurrogate] characterRangeAtPoint:point];
464 - (void)insertText:(NSString*)
text {
465 [[
self textInputSurrogate] insertText:text];
468 - (void)deleteBackward {
469 [[
self textInputSurrogate] deleteBackward];
472 #pragma mark - UIKeyInput overrides
475 return [[
self textInputSurrogate] hasText];
478 #pragma mark - UIResponder overrides
480 - (void)cut:(
id)sender {
481 [[
self textInputSurrogate] cut:sender];
484 - (void)copy:(
id)sender {
485 [[
self textInputSurrogate] copy:sender];
488 - (void)paste:(
id)sender {
489 [[
self textInputSurrogate] paste:sender];
494 - (void)selectAll:(
id)sender {
495 [[
self textInputSurrogate] selectAll:sender];
498 - (void)
delete:(
id)sender {
499 [[
self textInputSurrogate] delete:sender];
502 - (BOOL)canPerformAction:(
SEL)action withSender:(id)sender {
503 return [[
self textInputSurrogate] canPerformAction:action withSender:sender];
NSDictionary * markedTextStyle
UITextRange * markedTextRange
id< UITextInputDelegate > inputDelegate
API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder UITextRange * selectedTextRange
CGRect caretRectForPosition
FlutterTextRange * _selectedTextRange
static FLUTTER_ASSERT_ARC const UIAccessibilityTraits kUIAccessibilityTraitUndocumentedEmptyLine
Interface that represents an accessibility bridge for iOS.
virtual UIView< UITextInput > * textInputView()=0
instancetype rangeWithNSRange:(NSRange range)