macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

dragImageForSelectionWithEvent:origin:

テキストビューの選択された文字をドラッグしはじめた時に呼び出されます
-(NSImage *)dragImageForSelectionWithEvent:(NSEvent *)event:
            origin:(NSPointPointer)origin:

解説

テキストビューの選択された文字をドラッグしはじめた時に呼び出されます。
サブクラスでオーバーライドします。
返した画像(NSImage)が、ドラッグ中の画像になります。

返り値

( NSImage * )

画像

引数

( NSEvent * )event
( NSPointPointer )origin

位置のポインタ

フレームワーク

ApplicationKit

クラス

NSTextView

Instance Methods

使用可能

10.0

参照

例文

#import "MyTextView.h"

@implementation MyTextView
- (void)mouseDown:(NSEvent *)event
{
NSLog(@"mouseDown");
[super mouseDown:event];
}
-(NSImage *)dragImageForSelectionWithEvent:(NSEvent *)event origin:(NSPointPointer)origin
{

NSLog(@"dragImageForSelectionWithEvent");
[super dragImageForSelectionWithEvent:event origin:origin];


return [NSImage imageNamed: @"NSApplicationIcon" ];
}
@end