Rensselaer Center for Open Source Software

Some work on following the caret.

12 files changed, 63 lines added, 3 lines removed

Changes

--- iOS/Genesis/Genesis/GNFileRepresentation.h 5e5aec474d49a49e31e4769cf4ca248416af5258
+++ iOS/Genesis/Genesis/GNFileRepresentation.h 78b651ddea3f81bf403c57cabdccd8fe2dc2b501
@@ -51,6 +51,7 @@
+-(void)insertionPointWillChange;
--- iOS/Genesis/Genesis/GNFileRepresentation.m 5e5aec474d49a49e31e4769cf4ca248416af5258
+++ iOS/Genesis/Genesis/GNFileRepresentation.m 78b651ddea3f81bf403c57cabdccd8fe2dc2b501
@@ -122,6 +122,8 @@
+    [self insertionPointWillChange];
+    
@@ -147,6 +149,8 @@
+    [self insertionPointWillChange];
+    
@@ -282,6 +286,12 @@
+                                                        object:self];
+}
+
+-(void)insertionPointWillChange
+{
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"kGNInsertionPointWillChange"
--- iOS/Genesis/Genesis/GNLineNumberTableView.m 5e5aec474d49a49e31e4769cf4ca248416af5258
+++ iOS/Genesis/Genesis/GNLineNumberTableView.m 78b651ddea3f81bf403c57cabdccd8fe2dc2b501
@@ -62,6 +62,7 @@
+    [scrollDelegate hideKeyboardOnScroll:YES];
--- iOS/Genesis/Genesis/GNScrollViewDelegate.h 5e5aec474d49a49e31e4769cf4ca248416af5258
+++ iOS/Genesis/Genesis/GNScrollViewDelegate.h 78b651ddea3f81bf403c57cabdccd8fe2dc2b501
@@ -17,6 +17,7 @@
-- (void)scrollViewDidScroll:(UIScrollView*)scrollView;
+-(void)scrollViewDidScroll:(UIScrollView*)scrollView;
+-(void)hideKeyboardOnScroll:(BOOL)hide;
--- iOS/Genesis/Genesis/GNTextView.h 5e5aec474d49a49e31e4769cf4ca248416af5258
+++ iOS/Genesis/Genesis/GNTextView.h 78b651ddea3f81bf403c57cabdccd8fe2dc2b501
@@ -37,6 +37,8 @@
+    
+    BOOL shouldDismissKeyboard;
--- iOS/Genesis/Genesis/GNTextView.m 5e5aec474d49a49e31e4769cf4ca248416af5258
+++ iOS/Genesis/Genesis/GNTextView.m 78b651ddea3f81bf403c57cabdccd8fe2dc2b501
@@ -15,6 +15,7 @@
+#import "GNFileRepresentation.h"
@@ -25,6 +26,16 @@
+        
+        // Register for insertion point changes
+        [[NSNotificationCenter defaultCenter] addObserver:self
+                                                 selector:@selector(insertionPointWillChange:)
+                                                     name:@"kGNInsertionPointChanged" 
+                                                   object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self
+                                                 selector:@selector(insertionPointChanged:)
+                                                     name:@"kGNInsertionPointChanged"
+                                                   object:nil];
@@ -69,6 +80,26 @@
+    
+    shouldDismissKeyboard = YES;
+}
+
+-(void)insertionPointWillChange:(id)object
+{
+    shouldDismissKeyboard = NO;
+}
+
+-(void)insertionPointChanged:(id)object
+{
+    NSUInteger insertionLine = [(GNFileRepresentation*)[object object] insertionLine];
+    
+    NSIndexPath* insertionPath = [NSIndexPath indexPathForRow:insertionLine inSection:0];
+    
+    shouldDismissKeyboard = NO;
+    
+    [textTableView scrollToRowAtIndexPath:insertionPath
+                         atScrollPosition:UITableViewScrollPositionMiddle
+                                 animated:YES];
@@ -102,8 +133,11 @@
-    // Dismiss the keyboard
-    [textInputManagerView resignFirstResponder];
+    if(shouldDismissKeyboard)
+    {
+        // Dismiss the keyboard
+        [textInputManagerView resignFirstResponder];
+    }
@@ -114,8 +148,19 @@
+-(void)hideKeyboardOnScroll:(BOOL)hide
+{
+    shouldDismissKeyboard = YES;
+}
+
+-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
+{
+    shouldDismissKeyboard = YES;
+}
+
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
Genesis • 57 weeks ago