20 @property(nonatomic, copy) NSString*
text;
25 @synthesize beginningOfDocument = _beginningOfDocument;
26 @synthesize endOfDocument = _endOfDocument;
31 @synthesize tokenizer = _tokenizer;
34 return self.text.length > 0;
37 - (NSString*)textInRange:(UITextRange*)range {
42 @"Expected a FlutterTextRange for range (got %@).", [range
class]);
44 NSAssert(textRange.location != NSNotFound,
@"Expected a valid text range.");
45 return [
self.text substringWithRange:textRange];
48 - (void)replaceRange:(UITextRange*)range withText:(NSString*)
text {
54 - (void)setMarkedText:(NSString*)markedText selectedRange:(NSRange)markedSelectedRange {
66 - (UITextRange*)textRangeFromPosition:(UITextPosition*)fromPosition
67 toPosition:(UITextPosition*)toPosition {
73 - (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
80 - (UITextPosition*)positionFromPosition:(UITextPosition*)position
81 inDirection:(UITextLayoutDirection)direction
82 offset:(NSInteger)offset {
89 - (NSComparisonResult)comparePosition:(UITextPosition*)position toPosition:(UITextPosition*)other {
96 - (NSInteger)offsetFromPosition:(UITextPosition*)from toPosition:(UITextPosition*)toPosition {
103 - (UITextPosition*)positionWithinRange:(UITextRange*)range
104 farthestInDirection:(UITextLayoutDirection)direction {
111 - (UITextRange*)characterRangeByExtendingPosition:(UITextPosition*)position
112 inDirection:(UITextLayoutDirection)direction {
119 - (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition*)position
120 inDirection:(UITextStorageDirection)direction {
122 return UITextWritingDirectionNatural;
125 - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection
126 forRange:(UITextRange*)range {
130 - (CGRect)firstRectForRange:(UITextRange*)range {
144 - (UITextPosition*)closestPositionToPoint:(CGPoint)point {
151 - (UITextPosition*)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange*)range {
158 - (NSArray*)selectionRectsForRange:(UITextRange*)range {
165 - (UITextRange*)characterRangeAtPoint:(CGPoint)point {
172 - (void)insertText:(NSString*)
text {
178 - (void)deleteBackward {
190 - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge
192 self = [
super initWithBridge:bridge uid:uid];
201 #pragma mark - SemanticsObject overrides
203 - (void)setSemanticsNode:(
const flutter::SemanticsNode*)node {
204 [
super setSemanticsNode:node];
205 _inactive_text_input.
text = @(node->value.data());
207 if ([
self node].HasFlag(flutter::SemanticsFlags::kIsFocused)) {
208 textInput.backingTextInputAccessibilityObject =
self;
211 textInput.frame = CGRectMake(0.0, 0.0, 1.0, 1.0);
212 }
else if (textInput.backingTextInputAccessibilityObject ==
self) {
213 textInput.backingTextInputAccessibilityObject = nil;
217 #pragma mark - UIAccessibility overrides
227 - (UIView<UITextInput>*)textInputSurrogate {
228 if ([
self node].HasFlag(flutter::SemanticsFlags::kIsFocused)) {
229 return [
self bridge]->textInputView();
231 return _inactive_text_input;
235 - (UIView*)textInputView {
236 return [
self textInputSurrogate];
239 - (void)accessibilityElementDidBecomeFocused {
240 if (![
self isAccessibilityBridgeAlive]) {
243 [[
self textInputSurrogate] accessibilityElementDidBecomeFocused];
244 [
super accessibilityElementDidBecomeFocused];
247 - (void)accessibilityElementDidLoseFocus {
248 if (![
self isAccessibilityBridgeAlive]) {
251 [[
self textInputSurrogate] accessibilityElementDidLoseFocus];
252 [
super accessibilityElementDidLoseFocus];
255 - (BOOL)accessibilityElementIsFocused {
256 if (![
self isAccessibilityBridgeAlive]) {
259 return [
self node].HasFlag(flutter::SemanticsFlags::kIsFocused);
262 - (BOOL)accessibilityActivate {
263 if (![
self isAccessibilityBridgeAlive]) {
266 return [[
self textInputSurrogate] accessibilityActivate];
269 - (NSString*)accessibilityLabel {
270 if (![
self isAccessibilityBridgeAlive]) {
274 NSString* label = [
super accessibilityLabel];
278 return [
self textInputSurrogate].accessibilityLabel;
281 - (NSString*)accessibilityHint {
282 if (![
self isAccessibilityBridgeAlive]) {
285 NSString* hint = [
super accessibilityHint];
289 return [
self textInputSurrogate].accessibilityHint;
292 - (NSString*)accessibilityValue {
293 if (![
self isAccessibilityBridgeAlive]) {
296 NSString* value = [
super accessibilityValue];
300 return [
self textInputSurrogate].accessibilityValue;
303 - (UIAccessibilityTraits)accessibilityTraits {
304 if (![
self isAccessibilityBridgeAlive]) {
307 UIAccessibilityTraits results =
308 [
super accessibilityTraits] | [
self textInputSurrogate].accessibilityTraits;
315 #pragma mark - UITextInput overrides
317 - (NSString*)textInRange:(UITextRange*)range {
318 return [[
self textInputSurrogate] textInRange:range];
321 - (void)replaceRange:(UITextRange*)range withText:(NSString*)
text {
322 return [[
self textInputSurrogate] replaceRange:range withText:text];
325 - (BOOL)shouldChangeTextInRange:(UITextRange*)range replacementText:(NSString*)
text {
326 return [[
self textInputSurrogate] shouldChangeTextInRange:range replacementText:text];
330 return [[
self textInputSurrogate] selectedTextRange];
333 - (void)setSelectedTextRange:(UITextRange*)range {
334 [[
self textInputSurrogate] setSelectedTextRange:range];
338 return [[
self textInputSurrogate] markedTextRange];
342 return [[
self textInputSurrogate] markedTextStyle];
345 - (void)setMarkedTextStyle:(NSDictionary*)style {
346 [[
self textInputSurrogate] setMarkedTextStyle:style];
349 - (void)setMarkedText:(NSString*)markedText selectedRange:(NSRange)selectedRange {
350 [[
self textInputSurrogate] setMarkedText:markedText selectedRange:selectedRange];
354 [[
self textInputSurrogate] unmarkText];
357 - (UITextStorageDirection)selectionAffinity {
358 return [[
self textInputSurrogate] selectionAffinity];
361 - (UITextPosition*)beginningOfDocument {
362 return [[
self textInputSurrogate] beginningOfDocument];
365 - (UITextPosition*)endOfDocument {
366 return [[
self textInputSurrogate] endOfDocument];
370 return [[
self textInputSurrogate] inputDelegate];
373 - (void)setInputDelegate:(id<UITextInputDelegate>)delegate {
374 [[
self textInputSurrogate] setInputDelegate:delegate];
377 - (id<UITextInputTokenizer>)tokenizer {
378 return [[
self textInputSurrogate] tokenizer];
381 - (UITextRange*)textRangeFromPosition:(UITextPosition*)fromPosition
382 toPosition:(UITextPosition*)toPosition {
383 return [[
self textInputSurrogate] textRangeFromPosition:fromPosition toPosition:toPosition];
386 - (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
387 return [[
self textInputSurrogate] positionFromPosition:position offset:offset];
390 - (UITextPosition*)positionFromPosition:(UITextPosition*)position
391 inDirection:(UITextLayoutDirection)direction
392 offset:(NSInteger)offset {
393 return [[
self textInputSurrogate] positionFromPosition:position
394 inDirection:direction
398 - (NSComparisonResult)comparePosition:(UITextPosition*)position toPosition:(UITextPosition*)other {
399 return [[
self textInputSurrogate] comparePosition:position toPosition:other];
402 - (NSInteger)offsetFromPosition:(UITextPosition*)from toPosition:(UITextPosition*)toPosition {
403 return [[
self textInputSurrogate] offsetFromPosition:from toPosition:toPosition];
406 - (UITextPosition*)positionWithinRange:(UITextRange*)range
407 farthestInDirection:(UITextLayoutDirection)direction {
408 return [[
self textInputSurrogate] positionWithinRange:range farthestInDirection:direction];
411 - (UITextRange*)characterRangeByExtendingPosition:(UITextPosition*)position
412 inDirection:(UITextLayoutDirection)direction {
413 return [[
self textInputSurrogate] characterRangeByExtendingPosition:position
414 inDirection:direction];
417 - (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition*)position
418 inDirection:(UITextStorageDirection)direction {
419 return [[
self textInputSurrogate] baseWritingDirectionForPosition:position inDirection:direction];
422 - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection
423 forRange:(UITextRange*)range {
424 [[
self textInputSurrogate] setBaseWritingDirection:writingDirection forRange:range];
427 - (CGRect)firstRectForRange:(UITextRange*)range {
428 return [[
self textInputSurrogate] firstRectForRange:range];
432 return [[
self textInputSurrogate] caretRectForPosition:position];
435 - (UITextPosition*)closestPositionToPoint:(CGPoint)point {
436 return [[
self textInputSurrogate] closestPositionToPoint:point];
439 - (UITextPosition*)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange*)range {
440 return [[
self textInputSurrogate] closestPositionToPoint:point withinRange:range];
443 - (NSArray*)selectionRectsForRange:(UITextRange*)range {
444 return [[
self textInputSurrogate] selectionRectsForRange:range];
447 - (UITextRange*)characterRangeAtPoint:(CGPoint)point {
448 return [[
self textInputSurrogate] characterRangeAtPoint:point];
451 - (void)insertText:(NSString*)
text {
452 [[
self textInputSurrogate] insertText:text];
455 - (void)deleteBackward {
456 [[
self textInputSurrogate] deleteBackward];
459 #pragma mark - UIKeyInput overrides
462 return [[
self textInputSurrogate] hasText];