From 19a9d29aa873edcf5624bed7fa9ee86662da0bfd Mon Sep 17 00:00:00 2001 From: Yan S Date: Mon, 28 Aug 2017 11:49:41 -0700 Subject: [PATCH] SEP-491 prerequisite: add textViewShouldBeginEditing: to ASEditableTextNodeDelegate (#535) * SEP-491 prerequisite: add textViewShouldBeginEditing: to ASEditableTextNodeDelegate * - added entry to CHANGELOG.md, addressed nit --- CHANGELOG.md | 1 + Source/ASEditableTextNode.h | 7 +++++++ Source/ASEditableTextNode.mm | 14 ++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ba86ee3b9..7deeff472a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Fix retain cycle between ASImageNode and PINAnimatedImage [Phil Larson](https://github.com/plarson) [#520](https://github.com/TextureGroup/Texture/pull/520) - Change the API for disabling logging from a compiler flag to a runtime C function ASDisableLogging(). [Adlai Holler](https://github.com/Adlai-Holler) [#528](https://github.com/TextureGroup/Texture/pull/528) - Table and collection views to consider content inset when calculating (default) element size range [Huy Nguyen](https://github.com/nguyenhuy) [#525](https://github.com/TextureGroup/Texture/pull/525) +- [ASEditableTextNode] added -editableTextNodeShouldBeginEditing to ASEditableTextNodeDelegate to mirror the corresponding method from UITextViewDelegate. [Yan S.](https://github.com/yans) [#535](https://github.com/TextureGroup/Texture/pull/535) ##2.4 - Fix an issue where inserting/deleting sections could lead to inconsistent supplementary element behavior. [Adlai Holler](https://github.com/Adlai-Holler) diff --git a/Source/ASEditableTextNode.h b/Source/ASEditableTextNode.h index db310f06b9..31dbfe7d03 100644 --- a/Source/ASEditableTextNode.h +++ b/Source/ASEditableTextNode.h @@ -158,6 +158,13 @@ NS_ASSUME_NONNULL_BEGIN @protocol ASEditableTextNodeDelegate @optional +/** + @abstract Asks the delegate if editing should begin for the text node. + @param editableTextNode An editable text node. + @discussion YES if editing should begin; NO if editing should not begin -- the default returns YES. + */ +- (BOOL)editableTextNodeShouldBeginEditing:(ASEditableTextNode *)editableTextNode; + /** @abstract Indicates to the delegate that the text node began editing. @param editableTextNode An editable text node. diff --git a/Source/ASEditableTextNode.mm b/Source/ASEditableTextNode.mm index fd35ea5e1f..d68182ed16 100644 --- a/Source/ASEditableTextNode.mm +++ b/Source/ASEditableTextNode.mm @@ -699,6 +699,12 @@ } #pragma mark - UITextView Delegate +- (BOOL)textViewShouldBeginEditing:(UITextView *)textView +{ + // Delegateify. + return [self _delegateShouldBeginEditing]; +} + - (void)textViewDidBeginEditing:(UITextView *)textView { // Delegateify. @@ -793,6 +799,14 @@ } #pragma mark - +- (BOOL)_delegateShouldBeginEditing +{ + if ([_delegate respondsToSelector:@selector(editableTextNodeShouldBeginEditing:)]) { + return [_delegate editableTextNodeShouldBeginEditing:self]; + } + return YES; +} + - (void)_delegateDidBeginEditing { if ([_delegate respondsToSelector:@selector(editableTextNodeDidBeginEditing:)])