mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-07 14:53:35 +00:00
ASEditableTextNode: added shouldCopy callback
This commit is contained in:
parent
16ce3e690a
commit
75d4f47c24
@ -211,6 +211,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (void)editableTextNodeDidFinishEditing:(ASEditableTextNode *)editableTextNode;
|
- (void)editableTextNodeDidFinishEditing:(ASEditableTextNode *)editableTextNode;
|
||||||
|
|
||||||
|
- (BOOL)editableTextNodeShouldCopy:(ASEditableTextNode *)editableTextNode;
|
||||||
- (BOOL)editableTextNodeShouldPaste:(ASEditableTextNode *)editableTextNode;
|
- (BOOL)editableTextNodeShouldPaste:(ASEditableTextNode *)editableTextNode;
|
||||||
- (ASEditableTextNodeTargetForAction * _Nullable)editableTextNodeTargetForAction:(SEL)action;
|
- (ASEditableTextNodeTargetForAction * _Nullable)editableTextNodeTargetForAction:(SEL)action;
|
||||||
- (BOOL)editableTextNodeShouldReturn:(ASEditableTextNode *)editableTextNode;
|
- (BOOL)editableTextNodeShouldReturn:(ASEditableTextNode *)editableTextNode;
|
||||||
|
|||||||
@ -86,6 +86,7 @@
|
|||||||
BOOL _initializedPrimaryInputLanguage;
|
BOOL _initializedPrimaryInputLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property (nonatomic, copy) bool (^shouldCopy)();
|
||||||
@property (nonatomic, copy) bool (^shouldPaste)();
|
@property (nonatomic, copy) bool (^shouldPaste)();
|
||||||
@property (nonatomic, copy) ASEditableTextNodeTargetForAction *(^targetForActionImpl)(SEL);
|
@property (nonatomic, copy) ASEditableTextNodeTargetForAction *(^targetForActionImpl)(SEL);
|
||||||
@property (nonatomic, copy) bool (^shouldReturn)();
|
@property (nonatomic, copy) bool (^shouldReturn)();
|
||||||
@ -163,6 +164,12 @@
|
|||||||
return [super targetForAction:action withSender:sender];
|
return [super targetForAction:action withSender:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)copy:(id)sender {
|
||||||
|
if (_shouldCopy == nil || _shouldCopy()) {
|
||||||
|
[super copy:sender];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)paste:(id)sender
|
- (void)paste:(id)sender
|
||||||
{
|
{
|
||||||
if (_shouldPaste == nil || _shouldPaste()) {
|
if (_shouldPaste == nil || _shouldPaste()) {
|
||||||
@ -336,6 +343,15 @@
|
|||||||
ASPanningOverriddenUITextView *textView = [[ASPanningOverriddenUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
|
ASPanningOverriddenUITextView *textView = [[ASPanningOverriddenUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
|
||||||
textView.initialPrimaryLanguage = _initialPrimaryLanguage;
|
textView.initialPrimaryLanguage = _initialPrimaryLanguage;
|
||||||
__weak ASEditableTextNode *weakSelf = self;
|
__weak ASEditableTextNode *weakSelf = self;
|
||||||
|
textView.shouldCopy = ^bool{
|
||||||
|
__strong ASEditableTextNode *strongSelf = weakSelf;
|
||||||
|
if (strongSelf != nil) {
|
||||||
|
if ([strongSelf->_delegate respondsToSelector:@selector(editableTextNodeShouldCopy:)]) {
|
||||||
|
return [strongSelf->_delegate editableTextNodeShouldCopy:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
textView.shouldPaste = ^bool{
|
textView.shouldPaste = ^bool{
|
||||||
__strong ASEditableTextNode *strongSelf = weakSelf;
|
__strong ASEditableTextNode *strongSelf = weakSelf;
|
||||||
if (strongSelf != nil) {
|
if (strongSelf != nil) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user