textView:draggedCell:inRect:event:atIndex:
テキストビューのアタッチメントセルをドラッグしようとしたときに呼び出されます
-(void)textView:(NSTextView *)view: draggedCell:(id <NSTextAttachmentCell>)cell: inRect:(NSRect)rect: event:(NSEvent *)event: atIndex:(unsigned)charIndex:
解説
テキストビューのアタッチメントセルをドラッグしようとしたときに呼び出されます。
返り値
( void )
なし
引数
( NSTextView * )view
テキストビュー
( id <NSTextAttachmentCell> )cell
アタッチメントセル
( NSRect )rect
セルのフレーム
( NSEvent * )event
イベント
( unsigned )charIndex
先頭からの番号(文字数)
フレームワーク
ApplicationKit
クラス
NSTextView
Instance Methods
使用可能
10.0
参照
例文
#import "MyObject.h" //TextViewからこのクラスにdelegateしている @implementation MyObject - (void)textView:(NSTextView *)aTextView draggedCell:(id <NSTextAttachmentCell>)attachmentCell inRect:(NSRect)cellFrame event:(NSEvent *)event atIndex:(unsigned)charIndex { NSLog([NSString stringWithFormat:@"cellFrame = %.1f,%.1f,%.1f,%.1f",cellFrame.origin.x,cellFrame.origin.y,cellFrame.size.width,cellFrame.size.height]); NSLog([NSString stringWithFormat:@"charIndex = %d",charIndex]); } - (IBAction)myAction:(id)sender { NSRange ran; //テキストアタッチメント NSTextAttachment *theAttachment; //ファイルラッパ NSFileWrapper *theWrapper = [[[NSFileWrapper alloc] initWithPath: [[NSBundle mainBundle] pathForResource:@"image" ofType:@"tiff"]] autorelease]; //テキストアタッチメント theAttachment = [[[NSTextAttachment alloc] initWithFileWrapper:theWrapper] autorelease]; // [[myOutlet textStorage] appendAttributedString: [NSAttributedString attributedStringWithAttachment:theAttachment]]; ran = NSMakeRange(1,3); [myOutlet insertText:@"<-clich!"]; [myOutlet smartInsertBeforeStringForString:@"sss" replacingRange:ran]; } @end