From c597bc3b2ad86c3a6f2e0848a69df9d5060deb41 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 17 Apr 2013 13:25:30 +1000 Subject: Implement firstRectForCharacterRange so that composition popups appear near insertion. --- cocoa/ScintillaView.mm | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 0b8fddf56..e01a2bf40 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -324,9 +324,34 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) //-------------------------------------------------------------------------------------------------- -- (NSRect) firstRectForCharacterRange: (NSRange) range -{ - return NSZeroRect; +- (NSRect) firstRectForCharacterRange: (NSRange) aRange +{ + NSRect rect; + rect.origin.x = [ScintillaView directCall: mOwner + message: SCI_POINTXFROMPOSITION + wParam: 0 + lParam: aRange.location]; + rect.origin.y = [ScintillaView directCall: mOwner + message: SCI_POINTYFROMPOSITION + wParam: 0 + lParam: aRange.location]; + int rangeEnd = aRange.location + aRange.length; + rect.size.width = [ScintillaView directCall: mOwner + message: SCI_POINTXFROMPOSITION + wParam: 0 + lParam: rangeEnd] - rect.origin.x; + rect.size.height = [ScintillaView directCall: mOwner + message: SCI_POINTYFROMPOSITION + wParam: 0 + lParam: rangeEnd] - rect.origin.y; + rect.size.height += [ScintillaView directCall: mOwner + message: SCI_TEXTHEIGHT + wParam: 0 + lParam: 0]; + rect = [[[self superview] superview] convertRect:rect toView:nil]; + rect = [self.window convertRectToScreen:rect]; + + return rect; } //-------------------------------------------------------------------------------------------------- -- cgit v1.2.3