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 {
200 self = [
super initWithBridge:bridge uid:uid];
209#pragma mark - SemanticsObject overrides
212 [
super setSemanticsNode:node];
213 _inactive_text_input.text = @(node->value.data());
216 textInput.backingTextInputAccessibilityObject =
self;
219 textInput.frame = CGRectMake(0.0, 0.0, 1.0, 1.0);
220 }
else if (textInput.backingTextInputAccessibilityObject ==
self) {
221 textInput.backingTextInputAccessibilityObject = nil;
225#pragma mark - UIAccessibility overrides
235- (UIView<UITextInput>*)textInputSurrogate {
237 return [
self bridge]->textInputView();
239 return _inactive_text_input;
243- (UIView*)textInputView {
244 return [
self textInputSurrogate];
247- (void)accessibilityElementDidBecomeFocused {
248 if (![
self isAccessibilityBridgeAlive]) {
251 [[
self textInputSurrogate] accessibilityElementDidBecomeFocused];
252 [
super accessibilityElementDidBecomeFocused];
255- (void)accessibilityElementDidLoseFocus {
256 if (![
self isAccessibilityBridgeAlive]) {
259 [[
self textInputSurrogate] accessibilityElementDidLoseFocus];
260 [
super accessibilityElementDidLoseFocus];
263- (
BOOL)accessibilityElementIsFocused {
264 if (![
self isAccessibilityBridgeAlive]) {
270- (
BOOL)accessibilityActivate {
271 if (![
self isAccessibilityBridgeAlive]) {
274 return [[
self textInputSurrogate] accessibilityActivate];
277- (NSString*)accessibilityLabel {
278 if (![
self isAccessibilityBridgeAlive]) {
282 NSString* label = [
super accessibilityLabel];
286 return [
self textInputSurrogate].accessibilityLabel;
289- (NSString*)accessibilityHint {
290 if (![
self isAccessibilityBridgeAlive]) {
293 NSString* hint = [
super accessibilityHint];
297 return [
self textInputSurrogate].accessibilityHint;
300- (NSString*)accessibilityValue {
301 if (![
self isAccessibilityBridgeAlive]) {
304 NSString*
value = [
super accessibilityValue];
308 return [
self textInputSurrogate].accessibilityValue;
311- (UIAccessibilityTraits)accessibilityTraits {
312 if (![
self isAccessibilityBridgeAlive]) {
315 UIAccessibilityTraits results =
316 [
super accessibilityTraits] | [
self textInputSurrogate].accessibilityTraits;
320 return results & (~kUIAccessibilityTraitUndocumentedEmptyLine);
323#pragma mark - UITextInput overrides
325- (NSString*)textInRange:(UITextRange*)range {
326 return [[
self textInputSurrogate] textInRange:range];
329- (void)replaceRange:(UITextRange*)range withText:(NSString*)
text {
330 return [[
self textInputSurrogate] replaceRange:range withText:text];
333- (
BOOL)shouldChangeTextInRange:(UITextRange*)range replacementText:(NSString*)
text {
334 return [[
self textInputSurrogate] shouldChangeTextInRange:range replacementText:text];
338 return [[
self textInputSurrogate] selectedTextRange];
341- (void)setSelectedTextRange:(UITextRange*)range {
342 [[
self textInputSurrogate] setSelectedTextRange:range];
346 return [[
self textInputSurrogate] markedTextRange];
350 return [[
self textInputSurrogate] markedTextStyle];
353- (void)setMarkedTextStyle:(NSDictionary*)style {
354 [[
self textInputSurrogate] setMarkedTextStyle:style];
357- (void)setMarkedText:(NSString*)markedText selectedRange:(NSRange)selectedRange {
358 [[
self textInputSurrogate] setMarkedText:markedText selectedRange:selectedRange];
362 [[
self textInputSurrogate] unmarkText];
365- (UITextStorageDirection)selectionAffinity {
366 return [[
self textInputSurrogate] selectionAffinity];
369- (UITextPosition*)beginningOfDocument {
370 return [[
self textInputSurrogate] beginningOfDocument];
373- (UITextPosition*)endOfDocument {
374 return [[
self textInputSurrogate] endOfDocument];
378 return [[
self textInputSurrogate] inputDelegate];
381- (void)setInputDelegate:(id<UITextInputDelegate>)delegate {
382 [[
self textInputSurrogate] setInputDelegate:delegate];
385- (id<UITextInputTokenizer>)tokenizer {
386 return [[
self textInputSurrogate] tokenizer];
389- (UITextRange*)textRangeFromPosition:(UITextPosition*)fromPosition
390 toPosition:(UITextPosition*)toPosition {
391 return [[
self textInputSurrogate] textRangeFromPosition:fromPosition toPosition:toPosition];
394- (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
395 return [[
self textInputSurrogate] positionFromPosition:position offset:offset];
398- (UITextPosition*)positionFromPosition:(UITextPosition*)position
399 inDirection:(UITextLayoutDirection)direction
400 offset:(NSInteger)offset {
401 return [[
self textInputSurrogate] positionFromPosition:position
402 inDirection:direction
406- (NSComparisonResult)comparePosition:(UITextPosition*)position toPosition:(UITextPosition*)other {
407 return [[
self textInputSurrogate] comparePosition:position toPosition:other];
410- (NSInteger)offsetFromPosition:(UITextPosition*)from toPosition:(UITextPosition*)toPosition {
411 return [[
self textInputSurrogate] offsetFromPosition:from toPosition:toPosition];
414- (UITextPosition*)positionWithinRange:(UITextRange*)range
415 farthestInDirection:(UITextLayoutDirection)direction {
416 return [[
self textInputSurrogate] positionWithinRange:range farthestInDirection:direction];
419- (UITextRange*)characterRangeByExtendingPosition:(UITextPosition*)position
420 inDirection:(UITextLayoutDirection)direction {
421 return [[
self textInputSurrogate] characterRangeByExtendingPosition:position
422 inDirection:direction];
425- (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition*)position
426 inDirection:(UITextStorageDirection)direction {
427 return [[
self textInputSurrogate] baseWritingDirectionForPosition:position inDirection:direction];
430- (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection
431 forRange:(UITextRange*)range {
432 [[
self textInputSurrogate] setBaseWritingDirection:writingDirection forRange:range];
435- (CGRect)firstRectForRange:(UITextRange*)range {
436 return [[
self textInputSurrogate] firstRectForRange:range];
440 return [[
self textInputSurrogate] caretRectForPosition:position];
443- (UITextPosition*)closestPositionToPoint:(CGPoint)point {
444 return [[
self textInputSurrogate] closestPositionToPoint:point];
447- (UITextPosition*)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange*)range {
448 return [[
self textInputSurrogate] closestPositionToPoint:point withinRange:range];
451- (NSArray*)selectionRectsForRange:(UITextRange*)range {
452 return [[
self textInputSurrogate] selectionRectsForRange:range];
455- (UITextRange*)characterRangeAtPoint:(CGPoint)point {
456 return [[
self textInputSurrogate] characterRangeAtPoint:point];
459- (void)insertText:(NSString*)
text {
460 [[
self textInputSurrogate] insertText:text];
463- (void)deleteBackward {
464 [[
self textInputSurrogate] deleteBackward];
467#pragma mark - UIKeyInput overrides
470 return [[
self textInputSurrogate] hasText];
473#pragma mark - UIResponder overrides
475- (void)cut:(
id)sender {
476 [[
self textInputSurrogate] cut:sender];
479- (void)copy:(
id)sender {
480 [[
self textInputSurrogate] copy:sender];
483- (void)paste:(
id)sender {
484 [[
self textInputSurrogate] paste:sender];
489- (void)selectAll:(
id)sender {
490 [[
self textInputSurrogate] selectAll:sender];
493- (void)
delete:(
id)sender {
494 [[
self textInputSurrogate] delete:sender];
497- (
BOOL)canPerformAction:(SEL)
action withSender:(
id)sender {
498 return [[
self textInputSurrogate] canPerformAction:action withSender:sender];
static FLUTTER_ASSERT_ARC const UIAccessibilityTraits kUIAccessibilityTraitUndocumentedEmptyLine
instancetype rangeWithNSRange:(NSRange range)
NSDictionary * markedTextStyle
UITextRange * markedTextRange
id< UITextInputDelegate > inputDelegate
API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder UITextRange * selectedTextRange
CGRect caretRectForPosition
FlutterTextRange * _selectedTextRange