1
This commit is contained in:
@@ -392,6 +392,7 @@ typedef NS_ENUM(NSInteger, KBClearPhase) {
|
||||
[[KBInputBufferManager shared] clearPendingClearSnapshot];
|
||||
[[KBInputBufferManager shared] commitLiveToManual];
|
||||
}
|
||||
[self kb_refreshSuggestionsAfterLongPressClear:shouldClear];
|
||||
}
|
||||
|
||||
#pragma mark - Clear Label
|
||||
@@ -499,6 +500,7 @@ typedef NS_ENUM(NSInteger, KBClearPhase) {
|
||||
#pragma mark - Clear
|
||||
|
||||
- (void)kb_clearAllInput {
|
||||
[self kb_clearCurrentWordIfPossible];
|
||||
UIResponder *start = (UIResponder *)([self kb_hostView] ?: self.backspaceButton);
|
||||
UIInputViewController *ivc = KBFindInputViewController(start);
|
||||
if (ivc) {
|
||||
@@ -659,4 +661,36 @@ typedef NS_ENUM(NSInteger, KBClearPhase) {
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)kb_clearCurrentWordIfPossible {
|
||||
UIResponder *start = (UIResponder *)([self kb_hostView] ?: self.backspaceButton);
|
||||
UIInputViewController *ivc = KBFindInputViewController(start);
|
||||
if (!ivc) { return; }
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
if ([ivc respondsToSelector:@selector(kb_clearCurrentWord)]) {
|
||||
[ivc performSelector:@selector(kb_clearCurrentWord)];
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)kb_refreshSuggestionsAfterLongPressClear:(BOOL)shouldClear {
|
||||
NSTimeInterval delay = shouldClear ? 0.06 : 0.0;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)),
|
||||
dispatch_get_main_queue(), ^{
|
||||
[self kb_scheduleContextRefreshResetSuppression:NO];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)kb_scheduleContextRefreshResetSuppression:(BOOL)resetSuppression {
|
||||
UIResponder *start = (UIResponder *)([self kb_hostView] ?: self.backspaceButton);
|
||||
UIInputViewController *ivc = KBFindInputViewController(start);
|
||||
if (!ivc) { return; }
|
||||
SEL sel = @selector(kb_scheduleContextRefreshResetSuppression:);
|
||||
if (![ivc respondsToSelector:sel]) { return; }
|
||||
void (*func)(id, SEL, BOOL) = (void *)[ivc methodForSelector:sel];
|
||||
if (func) {
|
||||
func(ivc, sel, resetSuppression);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -293,10 +293,7 @@
|
||||
|
||||
- (BOOL)kb_shouldShowSuggestions {
|
||||
if (self.emojiPanelVisible) { return NO; }
|
||||
if (![KBBackspaceUndoManager shared].hasUndo && self.suggestionBarHasItems) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
return self.suggestionBarHasItems;
|
||||
}
|
||||
|
||||
- (void)kb_applySuggestionVisibility {
|
||||
|
||||
Reference in New Issue
Block a user