mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-26 00:09:41 +03:00
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:
parent
b925439a14
commit
fc6125f79a
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user