macOS/iOS API解説

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

目次

dragPromisedFilesOfTypes:fromRect:source:slideBack:event:

ドラッグを開始する
-(BOOL)dragPromisedFilesOfTypes:(NSArray *)typeArray:
            fromRect:(NSRect )aRect:
            source:(id)sourceObject:
            slideBack:(BOOL)slideBack:
            event:(NSEvent *)theEvent:

解説

ドラッグを開始する

返り値

( BOOL )

YES/NO

引数

( NSArray * )typeArray
( NSRect  )aRect

矩形

( id )sourceObject

ドラッグ元のオブジェクト

( BOOL )slideBack

ライドバックするか

( NSEvent * )theEvent

フレームワーク

ApplicationKit

クラス

NSView

Instance Methods

使用可能

10.2

参照

-dragImage:at:offset:event:pasteboard:source:slideBack:
-shouldDelayWindowOrderingForEvent:

例文

#import "MyImageView.h"

@implementation MyImageView
-(void)mouseDown:(NSEvent *)event
{
NSPoint curPoint = [self convertPoint:[event locationInWindow] fromView:nil];
        NSLog([NSString stringWithFormat:@"%.1f,%.1f",curPoint.x,curPoint.y]);

    if ([self dragPromisedFilesOfTypes:[NSArray arrayWithObjects:@"'TEXT'",nil]
                fromRect:   NSMakeRect(curPoint.x-16,curPoint.y-16,curPoint.x,curPoint.y)
                source:     nil
                slideBack:  YES
                event:      event
      ]){
    NSLog(@"YES");
    }else{
    NSLog(@"NO");
    }

}

@end