< prev index next >

modules/graphics/src/main/native-glass/mac/GlassView3D.m

Print this page




 671     [self unmarkText];
 672     self->imEnabled = enabled;
 673 }
 674 
 675 /*
 676  NSTextInputClient protocol implementation follows here.
 677  */
 678 
 679 - (void)doCommandBySelector:(SEL)aSelector
 680 {
 681     IMLOG("doCommandBySelector called ");
 682     // In case the IM was stopped with a mouse and the next typed key
 683     // is a special command key (backspace, tab, etc.)
 684     self->shouldProcessKeyEvent = YES;
 685 }
 686 
 687 - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
 688 {
 689     IMLOG("insertText called with string: %s", [aString UTF8String]);
 690     if ([self->nsAttrBuffer length] > 0 || [aString length] > 1) { 
 691         [self->_delegate notifyInputMethod:aString attr:4 length:(int)[aString length] cursor:(int)[aString length] ];
 692         self->shouldProcessKeyEvent = NO;
 693     } else {
 694         self->shouldProcessKeyEvent = YES;
 695     }
 696     self->nsAttrBuffer = [self->nsAttrBuffer initWithString:@""];
 697 }
 698 
 699 - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replacementRange:(NSRange)replacementRange
 700 {
 701     if (!self->imEnabled) {
 702         self->shouldProcessKeyEvent = YES;
 703         return;
 704     }
 705     BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
 706     NSAttributedString *attrString = (isAttributedString ? (NSAttributedString *)aString : nil);
 707     NSString *incomingString = (isAttributedString ? [aString string] : aString);
 708     IMLOG("setMarkedText called, attempt to set string to %s", [incomingString UTF8String]);
 709     [self->_delegate notifyInputMethod:incomingString attr:1 length:0 cursor:(int)[incomingString length] ];
 710     self->nsAttrBuffer = (attrString == nil ? [self->nsAttrBuffer initWithString:incomingString] 
 711                                             : [self->nsAttrBuffer initWithAttributedString: attrString]);
 712     self->shouldProcessKeyEvent = NO;
 713 }
 714 
 715 - (void) unmarkText
 716 {
 717     IMLOG("unmarkText called\n");
 718     if (self->nsAttrBuffer != nil && self->nsAttrBuffer.length != 0) {
 719         self->nsAttrBuffer = [self->nsAttrBuffer initWithString:@""];
 720         [self->_delegate notifyInputMethod:@"" attr:4 length:0 cursor:0 ];
 721     }
 722     self->shouldProcessKeyEvent = YES;
 723 }
 724 
 725 - (BOOL) hasMarkedText
 726 {
 727     BOOL hmText = (self->imEnabled ? (self->nsAttrBuffer.length == 0 ? FALSE : TRUE) : FALSE);
 728     IMLOG("hasMarkedText called return %s ", (hmText ? "true" : "false"));
 729     return hmText;
 730 }
 731 
 732 - (NSRange) markedRange
 733 {
 734     IMLOG("markedRange called, return range in attributed string");
 735     if (self->imEnabled) {
 736         return NSMakeRange(0, self->nsAttrBuffer.length);
 737     } else {
 738         return NSMakeRange(NSNotFound, 0);
 739     }
 740 }




 671     [self unmarkText];
 672     self->imEnabled = enabled;
 673 }
 674 
 675 /*
 676  NSTextInputClient protocol implementation follows here.
 677  */
 678 
 679 - (void)doCommandBySelector:(SEL)aSelector
 680 {
 681     IMLOG("doCommandBySelector called ");
 682     // In case the IM was stopped with a mouse and the next typed key
 683     // is a special command key (backspace, tab, etc.)
 684     self->shouldProcessKeyEvent = YES;
 685 }
 686 
 687 - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
 688 {
 689     IMLOG("insertText called with string: %s", [aString UTF8String]);
 690     if ([self->nsAttrBuffer length] > 0 || [aString length] > 1) { 
 691         [self->_delegate notifyInputMethod:aString attr:4 length:(int)[aString length] cursor:(int)[aString length] selectedRange: NSMakeRange(NSNotFound, 0)];
 692         self->shouldProcessKeyEvent = NO;
 693     } else {
 694         self->shouldProcessKeyEvent = YES;
 695     }
 696     self->nsAttrBuffer = [self->nsAttrBuffer initWithString:@""];
 697 }
 698 
 699 - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replacementRange:(NSRange)replacementRange
 700 {
 701     if (!self->imEnabled) {
 702         self->shouldProcessKeyEvent = YES;
 703         return;
 704     }
 705     BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
 706     NSAttributedString *attrString = (isAttributedString ? (NSAttributedString *)aString : nil);
 707     NSString *incomingString = (isAttributedString ? [aString string] : aString);
 708     IMLOG("setMarkedText called, attempt to set string to %s", [incomingString UTF8String]);
 709     [self->_delegate notifyInputMethod:incomingString attr:1 length:0 cursor:(int)[incomingString length] selectedRange:selectionRange ];
 710     self->nsAttrBuffer = (attrString == nil ? [self->nsAttrBuffer initWithString:incomingString] 
 711                                             : [self->nsAttrBuffer initWithAttributedString: attrString]);
 712     self->shouldProcessKeyEvent = NO;
 713 }
 714 
 715 - (void) unmarkText
 716 {
 717     IMLOG("unmarkText called\n");
 718     if (self->nsAttrBuffer != nil && self->nsAttrBuffer.length != 0) {
 719         self->nsAttrBuffer = [self->nsAttrBuffer initWithString:@""];
 720         [self->_delegate notifyInputMethod:@"" attr:4 length:0 cursor:0 selectedRange: NSMakeRange(NSNotFound, 0)];
 721     }
 722     self->shouldProcessKeyEvent = YES;
 723 }
 724 
 725 - (BOOL) hasMarkedText
 726 {
 727     BOOL hmText = (self->imEnabled ? (self->nsAttrBuffer.length == 0 ? FALSE : TRUE) : FALSE);
 728     IMLOG("hasMarkedText called return %s ", (hmText ? "true" : "false"));
 729     return hmText;
 730 }
 731 
 732 - (NSRange) markedRange
 733 {
 734     IMLOG("markedRange called, return range in attributed string");
 735     if (self->imEnabled) {
 736         return NSMakeRange(0, self->nsAttrBuffer.length);
 737     } else {
 738         return NSMakeRange(NSNotFound, 0);
 739     }
 740 }


< prev index next >