changeset 20713:6baaec6722b9 draft

-Codechange: [OSX] Make our view aware of text input by IMEs.
author Michael Lutz <michi@icosahedron.de>
date Fri, 26 Jul 2013 01:26:54 +0200
parents cfe87e917bcd
children fdf6e212a787
files src/video/cocoa/cocoa_v.h src/video/cocoa/cocoa_v.mm
diffstat 2 files changed, 60 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -232,7 +232,7 @@
 @end
 
 /** Subclass of NSView to fix Quartz rendering and mouse awareness */
-@interface OTTD_CocoaView : NSView {
+@interface OTTD_CocoaView : NSView <NSTextInput> {
 	CocoaSubdriver *driver;
 	NSTrackingRectTag trackingtag;
 }
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -799,6 +799,65 @@
 	HandleTextInput([ s UTF8String ]);
 }
 
+/** Set a new marked text and reposition the caret. */
+- (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange
+{
+}
+
+/** Unmark the current marked text. */
+- (void)unmarkText
+{
+	HandleTextInput(NULL, true);
+}
+
+/** Get the caret position. */
+- (NSRange)selectedRange
+{
+	return NSMakeRange(NSNotFound, 0);
+}
+
+/** Get the currently marked range. */
+- (NSRange)markedRange
+{
+	return NSMakeRange(NSNotFound, 0);
+}
+
+/** Is any text marked? */
+- (BOOL)hasMarkedText
+{
+	return NO;
+}
+
+/** Get a string corresponding to the given range. */
+- (NSAttributedString *)attributedSubstringFromRange:(NSRange)theRange
+{
+	return nil;
+}
+
+/** Get the character that is rendered at the given point. */
+- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
+{
+	return NSNotFound;
+}
+
+/** Get the bounding rect for the given range. */
+- (NSRect)firstRectForCharacterRange:(NSRange)aRange
+{
+	return NSMakeRect(0, 0, 0, 0);
+}
+
+/** Get all string attributes that we can process for marked text. */
+- (NSArray*)validAttributesForMarkedText
+{
+	return [ NSArray array ];
+}
+
+/** Identifier for this text input instance. */
+- (NSInteger)conversationIdentifier
+{
+	return 0;
+}
+
 /** Invoke the selector if we implement it. */
 - (void)doCommandBySelector:(SEL)aSelector
 {