aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2011-01-19 20:19:29 +0000
committerBibiko <bibiko@eva.mpg.de>2011-01-19 20:19:29 +0000
commit06c03ea6543b7d38d1b17d5ac8f8416814708eb5 (patch)
tree2fbaecf4637f0ef1f62115686d1bd46150875246 /Source/SPTextView.m
parentc27e06e95d403f6100b4386487a83a466cf696bc (diff)
downloadsequelpro-06c03ea6543b7d38d1b17d5ac8f8416814708eb5.tar.gz
sequelpro-06c03ea6543b7d38d1b17d5ac8f8416814708eb5.tar.bz2
sequelpro-06c03ea6543b7d38d1b17d5ac8f8416814708eb5.zip
• improved caret positioning for ordering out any kind of tooltip windows esp. for first word after soft-wrapping
• fixed tooltip positioning for SPTextView - do not take the mouse location instead take the caret position
Diffstat (limited to 'Source/SPTextView.m')
-rw-r--r--Source/SPTextView.m19
1 files changed, 7 insertions, 12 deletions
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index 32c692b5..bfc90581 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -817,6 +817,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
if (completionIsOpen) [completionPopup close], completionPopup = nil;
+
completionIsOpen = YES;
completionPopup = [[SPNarrowDownCompletion alloc] initWithItems:[self suggestionsForSQLCompletionWith:currentWord dictMode:isDictMode browseMode:dbBrowseMode withTableName:tableName withDbName:dbName]
alreadyTyped:filter
@@ -842,19 +843,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
completionParseRangeLocation = parseRange.location;
//Get the NSPoint of the first character of the current word
- NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(completionRange.location,0) actualCharacterRange:NULL];
+ NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(completionRange.location,1) actualCharacterRange:NULL];
NSRect boundingRect = [[self layoutManager] boundingRectForGlyphRange:glyphRange inTextContainer:[self textContainer]];
- boundingRect = [self convertRect: boundingRect toView: NULL];
- NSPoint pos = [[self window] convertBaseToScreen: NSMakePoint(boundingRect.origin.x + boundingRect.size.width,boundingRect.origin.y + boundingRect.size.height)];
-
- // TODO: check if needed
- // if(filter)
- // pos.x -= [filter sizeWithAttributes:[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]].width;
-
- // Adjust list location to be under the current word or insertion point
+ boundingRect = [self convertRect:boundingRect toView:nil];
+ NSPoint pos = [[self window] convertBaseToScreen:NSMakePoint(boundingRect.origin.x + boundingRect.size.width,boundingRect.origin.y + boundingRect.size.height)];
pos.y -= [[self font] pointSize]*1.25;
-
[completionPopup setCaretPos:pos];
+
[completionPopup orderFront:self];
[completionPopup insertAutocompletePlaceholder];
@@ -1408,7 +1403,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
isQueryingDBStructure:NO];
//Get the NSPoint of the first character of the current word
- NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(aRange.location,0) actualCharacterRange:NULL];
+ NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(aRange.location,1) actualCharacterRange:NULL];
NSRect boundingRect = [[self layoutManager] boundingRectForGlyphRange:glyphRange inTextContainer:[self textContainer]];
boundingRect = [self convertRect: boundingRect toView: NULL];
NSPoint pos = [[self window] convertBaseToScreen: NSMakePoint(boundingRect.origin.x + boundingRect.size.width,boundingRect.origin.y + boundingRect.size.height)];
@@ -1564,7 +1559,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
isQueryingDBStructure:NO];
//Get the NSPoint of the first character of the current word
- NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(r2.location,0) actualCharacterRange:NULL];
+ NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(r2.location,1) actualCharacterRange:NULL];
NSRect boundingRect = [[self layoutManager] boundingRectForGlyphRange:glyphRange inTextContainer:[self textContainer]];
boundingRect = [self convertRect: boundingRect toView: NULL];
NSPoint pos = [[self window] convertBaseToScreen: NSMakePoint(boundingRect.origin.x + boundingRect.size.width,boundingRect.origin.y + boundingRect.size.height)];