From ca5e9e7dc3ef1ec4872dcf68f477d148c35c6e81 Mon Sep 17 00:00:00 2001 From: Connor Montgomery Date: Thu, 30 Jul 2015 15:19:00 -0400 Subject: [PATCH] Add support for configuring on ASEditableTextNode. --- AsyncDisplayKit/ASEditableTextNode.h | 5 +++++ AsyncDisplayKit/ASEditableTextNode.mm | 9 +++++++++ examples/EditableText/Sample/ViewController.m | 1 + 3 files changed, 15 insertions(+) diff --git a/AsyncDisplayKit/ASEditableTextNode.h b/AsyncDisplayKit/ASEditableTextNode.h index fb3354c8e8..bef4a0a81b 100644 --- a/AsyncDisplayKit/ASEditableTextNode.h +++ b/AsyncDisplayKit/ASEditableTextNode.h @@ -50,6 +50,11 @@ //! @abstract The text input mode used by the receiver's keyboard, if it is visible. This value is undefined if the receiver is not the first responder. @property (nonatomic, readonly) UITextInputMode *textInputMode; +/* + @abstract The returnKeyType of the keyboard. This value defaults to UIReturnKeyDefault. + */ +@property (nonatomic, readwrite) UIReturnKeyType returnKeyType; + /** @abstract Indicates whether the receiver's text view is the first responder, and thus has the keyboard visible and is prepared for editing by the user. @result YES if the receiver's text view is the first-responder; NO otherwise. diff --git a/AsyncDisplayKit/ASEditableTextNode.mm b/AsyncDisplayKit/ASEditableTextNode.mm index 3761134481..9f51c59619 100644 --- a/AsyncDisplayKit/ASEditableTextNode.mm +++ b/AsyncDisplayKit/ASEditableTextNode.mm @@ -77,6 +77,7 @@ _textKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero]; _textKitComponents.layoutManager.delegate = self; _wordKerner = [[ASTextNodeWordKerner alloc] init]; + _returnKeyType = UIReturnKeyDefault; // Create the placeholder scaffolding. _placeholderTextKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero]; @@ -138,6 +139,7 @@ _textKitComponents.textView.delegate = self; _textKitComponents.textView.editable = YES; _textKitComponents.textView.typingAttributes = _typingAttributes; + _textKitComponents.textView.returnKeyType = _returnKeyType; _textKitComponents.textView.accessibilityHint = _placeholderTextKitComponents.textStorage.string; configureTextView(_textKitComponents.textView); [self.view addSubview:_textKitComponents.textView]; @@ -346,6 +348,13 @@ return [_textKitComponents.textView textInputMode]; } +- (void)setReturnKeyType:(UIReturnKeyType)returnKeyType +{ + ASDN::MutexLocker l(_textKitLock); + _returnKeyType = returnKeyType; + [_textKitComponents.textView setReturnKeyType:_returnKeyType]; +} + - (BOOL)isFirstResponder { ASDN::MutexLocker l(_textKitLock); diff --git a/examples/EditableText/Sample/ViewController.m b/examples/EditableText/Sample/ViewController.m index 595458ec85..91288dfad5 100644 --- a/examples/EditableText/Sample/ViewController.m +++ b/examples/EditableText/Sample/ViewController.m @@ -31,6 +31,7 @@ // simple editable text node. here we use it synchronously, but it fully supports async layout & display _textNode = [[ASEditableTextNode alloc] init]; + _textNode.returnKeyType = UIReturnKeyDone; _textNode.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.1f]; // with placeholder text (displayed if the user hasn't entered text)