summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2013-08-05 20:37:53 +0000
committermichi_cc <michi_cc@openttd.org>2013-08-05 20:37:53 +0000
commit30867c487f17ca13744977c7873f4e1cf214fd33 (patch)
tree7b7c7bcf951dba613468a4431c0f7510be76180a /src/video
parente2ec0ddb030afd4e7bdf08d1a8f3cb9361388eae (diff)
downloadopenttd-30867c487f17ca13744977c7873f4e1cf214fd33.tar.xz
(svn r25691) -Add: [OSX] Support for mouse selection in the IME composition string.
Diffstat (limited to 'src/video')
-rw-r--r--src/video/cocoa/cocoa_v.mm11
1 files changed, 10 insertions, 1 deletions
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. */