aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-12-23 01:55:28 +0000
committerrowanbeentje <rowan@beent.je>2012-12-23 01:55:28 +0000
commitc65704f3a87c14b9dbe16c976d7afcb0f175a63f (patch)
tree402eeb32bc64b073dcecfba5eed1b819c47f2a27
parent0267bc701a7ec28918a90140b4c6f9a8cfff30df (diff)
downloadsequelpro-c65704f3a87c14b9dbe16c976d7afcb0f175a63f.tar.gz
sequelpro-c65704f3a87c14b9dbe16c976d7afcb0f175a63f.tar.bz2
sequelpro-c65704f3a87c14b9dbe16c976d7afcb0f175a63f.zip
- Correctly draw/update the selection highlight within the SPTextView used in the Custom Query Editor (among others) as the selection is changed with the mouse
-rw-r--r--Source/SPTextView.m23
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index dcb9dad7..5e324d28 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -3242,6 +3242,29 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS
return YES;
}
+/**
+ * Selection range changes
+ * Listen to selection range change events and use changes of state between selection and no
+ * selection to redraw the hilight state
+ */
+- (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange granularity:(NSSelectionGranularity)granularity
+{
+ NSUInteger currentSelectionLength = [self selectedRange].length;
+
+ // If selection started/ended, redraw the background in the current query area
+ if ([self shouldHiliteQuery] && (currentSelectionLength && !proposedSelRange.length) || (!currentSelectionLength && proposedSelRange.length)) {
+ NSUInteger i = 0, rectCount = 0;
+ NSRect* rectsToUpdate = [[self layoutManager] rectArrayForCharacterRange:[self queryRange]
+ withinSelectedCharacterRange:[self queryRange]
+ inTextContainer:[self textContainer]
+ rectCount:&rectCount];
+ for (i = 0; i < rectCount; i++) {
+ [self setNeedsDisplayInRect:rectsToUpdate[i]];
+ }
+ }
+
+ return [super selectionRangeForProposedRange:proposedSelRange granularity:granularity];
+}
#pragma mark -
#pragma mark delegates