From 30867c487f17ca13744977c7873f4e1cf214fd33 Mon Sep 17 00:00:00 2001 From: michi_cc Date: Mon, 5 Aug 2013 20:37:53 +0000 Subject: (svn r25691) -Add: [OSX] Support for mouse selection in the IME composition string. --- src/video/cocoa/cocoa_v.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/video/cocoa') diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index e4897ac50..69af4786d 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -909,7 +909,16 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count) /** Get the character that is rendered at the given point. */ - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint { - return NSNotFound; + if (!EditBoxInGlobalFocus()) return NSNotFound; + + NSPoint view_pt = [ self convertPoint:[ [ self window ] convertScreenToBase:thePoint ] fromView:nil ]; + + Point pt = { view_pt.x, [ self frame ].size.height - view_pt.y }; + + const char *ch = _focused_window->GetTextCharacterAtPosition(pt); + if (ch == NULL) return NSNotFound; + + return CountUtf16Units(_focused_window->GetFocusedText(), ch); } /** Get the bounding rect for the given range. */ -- cgit v1.2.3-70-g09d2