Minimal implementation of NSTextInput protocol. Allows accented characters to be typed. Might not work with other, more complex input methods (chinese, ...)

svn path=/trunk/netsurf/; revision=11930
This commit is contained in:
Sven Weidauer 2011-03-07 09:01:42 +00:00
parent b925439a14
commit fc6125f79a
2 changed files with 66 additions and 1 deletions

View File

@ -22,7 +22,7 @@
@class LocalHistoryController;
@interface BrowserView : ScrollableView {
@interface BrowserView : ScrollableView <NSTextInput> {
struct browser_window *browser;
NSPoint caretPoint;
@ -36,6 +36,8 @@
BOOL historyVisible;
LocalHistoryController *history;
NSString *markedText;
}
@property (readwrite, assign, nonatomic) struct browser_window *browser;

View File

@ -32,6 +32,8 @@
@interface BrowserView ()
@property (readwrite, copy, nonatomic) NSString *markedText;
- (void) scrollHorizontal: (CGFloat) amount;
- (void) scrollVertical: (CGFloat) amount;
- (CGFloat) pageScroll;
@ -54,6 +56,7 @@
@synthesize browser;
@synthesize caretTimer;
@synthesize markedText;
static const CGFloat CaretWidth = 1.0;
static const NSTimeInterval CaretBlinkTime = 0.8;
@ -72,6 +75,7 @@ static NSMutableArray *cocoa_reformat_pending = nil;
- (void) dealloc;
{
[self setCaretTimer: nil];
[self setMarkedText: nil];
[history release];
[super dealloc];
@ -300,6 +304,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
break;
}
}
[self setMarkedText: nil];
}
- (void) moveLeft: (id)sender;
@ -623,5 +628,63 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
return YES;
}
// MARK: -
// MARK: NSTextInput protocol implementation
- (void) setMarkedText: (id) aString selectedRange: (NSRange) selRange
{
[markedText release];
markedText = [aString isEqualToString: @""] ? nil : [aString copy];
}
- (void) unmarkText
{
[self setMarkedText: nil];
}
- (BOOL) hasMarkedText
{
return markedText != nil;
}
- (NSInteger) conversationIdentifier
{
return (NSInteger)self;
}
- (NSAttributedString *) attributedSubstringFromRange: (NSRange) theRange
{
return [[[NSAttributedString alloc] initWithString: @""] autorelease];
}
- (NSRange) markedRange
{
return NSMakeRange( NSNotFound, 0 );
}
- (NSRange) selectedRange
{
return NSMakeRange( NSNotFound, 0 );
}
- (NSRect) firstRectForCharacterRange: (NSRange) theRange
{
return NSZeroRect;
}
- (NSUInteger) characterIndexForPoint: (NSPoint) thePoint
{
return 0;
}
- (NSArray *) validAttributesForMarkedText
{
return [NSArray array];
}
- (void) doCommandBySelector: (SEL) sel;
{
[super doCommandBySelector: sel];
}
@end