Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AsyncDisplayKit/ASEditableTextNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 textContainerInset of both the placeholder and typed textView. This value defaults to UIEdgeInsetsZero.
*/
@property (nonatomic, readwrite) UIEdgeInsets textContainerInset;

/*
@abstract The returnKeyType of the keyboard. This value defaults to UIReturnKeyDefault.
*/
Expand Down
14 changes: 12 additions & 2 deletions AsyncDisplayKit/ASEditableTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ - (instancetype)init
_textKitComponents.layoutManager.delegate = self;
_wordKerner = [[ASTextNodeWordKerner alloc] init];
_returnKeyType = UIReturnKeyDefault;

_textContainerInset = UIEdgeInsetsZero;

// Create the placeholder scaffolding.
_placeholderTextKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
_placeholderTextKitComponents.layoutManager.delegate = self;
Expand Down Expand Up @@ -122,7 +123,7 @@ - (void)didLoad
textView.backgroundColor = nil;
textView.opaque = NO;
}
textView.textContainerInset = UIEdgeInsetsZero;
textView.textContainerInset = self.textContainerInset;
textView.clipsToBounds = NO; // We don't want selection handles cut off.
};

Expand Down Expand Up @@ -175,6 +176,15 @@ - (void)setBackgroundColor:(UIColor *)backgroundColor
_placeholderTextKitComponents.textView.backgroundColor = backgroundColor;
}

- (void)setTextContainerInset:(UIEdgeInsets)textContainerInset
{
ASDN::MutexLocker l(_textKitLock);

_textContainerInset = textContainerInset;
_textKitComponents.textView.textContainerInset = textContainerInset;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future I'd still prefer we be more explicit about this — a comment is fine if it is logically certain that an if (nodeLoaded) check is not needed. As a future reader / author in this code, though, it isn't immediately obvious that these latter two lines are intended to be no-ops and should not trigger the views to be created.

_placeholderTextKitComponents.textView.textContainerInset = textContainerInset;
}

- (void)setOpaque:(BOOL)opaque
{
[super setOpaque:opaque];
Expand Down