Add support for configuring on ASEditableTextNode.

This commit is contained in:
Connor Montgomery
2015-07-30 15:19:00 -04:00
parent 5482213e2e
commit ca5e9e7dc3
3 changed files with 15 additions and 0 deletions

View File

@@ -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.

View File

@@ -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);

View File

@@ -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)