RCTBackedTextInputDelegate.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <UIKit/UIKit.h>
  8. @protocol RCTBackedTextInputViewProtocol;
  9. NS_ASSUME_NONNULL_BEGIN
  10. @protocol RCTBackedTextInputDelegate <NSObject>
  11. - (BOOL)textInputShouldBeginEditing; // Return `NO` to disallow editing.
  12. - (void)textInputDidBeginEditing;
  13. - (BOOL)textInputShouldEndEditing; // Return `YES` to allow editing to stop and to resign first responder status. `NO` to disallow the editing session to end.
  14. - (void)textInputDidEndEditing; // May be called if forced even if `textInputShouldEndEditing` returns `NO` (e.g. view removed from window) or `[textInput endEditing:YES]` called.
  15. - (BOOL)textInputShouldReturn; // May be called right before `textInputShouldEndEditing` if "Return" button was pressed.
  16. - (void)textInputDidReturn;
  17. /*
  18. * Called before any change in the TextInput. The delegate has the opportunity to change the replacement string or reject the change completely.
  19. * To change the replacement, return the changed version of the `text`.
  20. * To accept the change, return `text` argument as-is.
  21. * To reject the change, return `nil`.
  22. */
  23. - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range;
  24. - (void)textInputDidChange;
  25. - (void)textInputDidChangeSelection;
  26. @optional
  27. - (void)scrollViewDidScroll:(UIScrollView *)scrollView;
  28. @end
  29. NS_ASSUME_NONNULL_END