Skip to content

Commit 03c4169

Browse files
committed
Send Tab after inserting doc
So the first token can be selected by default. Signed-off-by: onevcat <onevcat@gmail.com>
1 parent 61b09fe commit 03c4169

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

VVDocumenter-Xcode/VVDocumenterManager.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,22 @@ - (void) textStorageDidChange:(NSNotification *)noti {
7777
//Set cursor before the inserted documentation. So we can use tab to begin edit.
7878
int baseIndentationLength = (int)[doc baseIndentation].length;
7979
[textView setSelectedRange:NSMakeRange(currentLineResult.range.location + baseIndentationLength, 0)];
80+
81+
//Send a 'tab' after insert the doc. For our lazy programmers. :)
82+
[self sendTabEvent];
8083
}
8184
}
8285
}
8386
}
8487

88+
-(void) sendTabEvent
89+
{
90+
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
91+
//kVK_Tab = 0x30, See http://forums.macrumors.com/archive/index.php/t-1216916.html
92+
CGEventRef tab = CGEventCreateKeyboardEvent(src, 0x30, true);
93+
CGEventTapLocation loc = kCGHIDEventTap;
94+
CGEventPost(loc, tab);
95+
CFRelease(tab);
96+
}
8597

8698
@end

0 commit comments

Comments
 (0)