Skip to content

Commit 782dc9e

Browse files
Ignacio Romero ZurbuchenIgnacio Romero
Ignacio Romero Zurbuchen
authored and
Ignacio Romero
committed
Disables auto-completion's text processing on iOS 9 when the keyboard trackpad is enabled on iPad. Fixes slackhq#267
1 parent bb07742 commit 782dc9e

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

Source/Classes/SLKTextView.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ typedef NS_OPTIONS(NSUInteger, SLKPastableMediaType) {
6767
/** YES if the magnifying glass is visible. */
6868
@property (nonatomic, getter=isLoupeVisible) BOOL loupeVisible;
6969

70+
/** YES if the keyboard track pad has been recognized. iOS 9 only. */
71+
@property (nonatomic, readonly, getter=isTrackpadEnabled) BOOL trackpadEnabled;
72+
7073
/** YES if autocorrection and spell checking are enabled. On iOS8, this property also controls the predictive QuickType bar from being visible. Default is YES. */
7174
@property (nonatomic, getter=isTypingSuggestionEnabled) BOOL typingSuggestionEnabled;
7275

Source/Classes/SLKTextView.m

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,31 @@ - (void)setTextAlignment:(NSTextAlignment)textAlignment
500500
}
501501

502502

503+
#pragma mark - UITextInput Overrides
504+
505+
- (void)beginFloatingCursorAtPoint:(CGPoint)point
506+
{
507+
_trackpadEnabled = YES;
508+
}
509+
510+
- (void)updateFloatingCursorAtPoint:(CGPoint)point
511+
{
512+
// Do something
513+
}
514+
515+
- (void)endFloatingCursor
516+
{
517+
_trackpadEnabled = NO;
518+
519+
// We still need to notify a selection change in the textview after the trackpad is disabled
520+
if (self.delegate && [self.delegate respondsToSelector:@selector(textViewDidChangeSelection:)]) {
521+
[self.delegate textViewDidChangeSelection:self];
522+
}
523+
524+
[[NSNotificationCenter defaultCenter] postNotificationName:SLKTextViewSelectedRangeDidChangeNotification object:self userInfo:nil];
525+
}
526+
527+
503528
#pragma mark - UIResponder Overrides
504529

505530
- (BOOL)canBecomeFirstResponder
@@ -594,11 +619,11 @@ - (void)paste:(id)sender
594619

595620
- (void)slk_willShowLoupe:(UIGestureRecognizer *)gesture
596621
{
597-
if (gesture.state == UIGestureRecognizerStateChanged) {
598-
self.loupeVisible = YES;
622+
if (gesture.state == UIGestureRecognizerStateBegan || gesture.state == UIGestureRecognizerStateChanged) {
623+
_loupeVisible = YES;
599624
}
600625
else {
601-
self.loupeVisible = NO;
626+
_loupeVisible = NO;
602627
}
603628

604629
// We still need to notify a selection change in the textview after the magnifying class is dismissed

Source/Classes/SLKTextViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ - (void)textSelectionDidChange
656656
}
657657

658658
// Skips if the loupe is visible or if there is a real text selection
659-
if (self.textView.isLoupeVisible || self.textView.selectedRange.length > 0) {
659+
if (self.textView.isLoupeVisible || self.textView.isTrackpadEnabled || self.textView.selectedRange.length > 0) {
660660
return;
661661
}
662662

0 commit comments

Comments
 (0)