macOS/iOS API解説

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

目次

mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:

マウスイベントを作って返します
+(NSEvent *)mouseEventWithType:(NSEventType)type:
              location:(NSPoint)location:
              modifierFlags:(unsigned int)flags:
              timestamp:(NSTimeInterval)time:
              windowNumber:(int)windowNum:
              context:(NSGraphicsContext *)context:
              eventNumber:(int)eventNumber:
              clickCount:(int)clickNumber:
              pressure:(float)pressure:

解説

マウスイベントを作って返します。

返り値

( NSEvent * )

イベント

引数

( NSEventType )type

イベントタイプ
● NSLeftMouseDown 左マウスボタンを押した
● NSLeftMouseUp
● NSRightMouseDown
● NSRightMouseUp
● NSMouseMoved
● NSLeftMouseDragged
● NSRightMouseDragged
● NSMouseEntered
● NSMouseExited
● NSKeyDown
● NSKeyUp
● NSFlagsChanged
● NSAppKitDefined
● NSSystemDefined
● NSApplicationDefined
● NSPeriodic
● NSCursorUpdate
● NSScrollWheel
● NSOtherMouseDown
● NSOtherMouseUp
● NSOtherMouseDragged

( NSPoint )location

指定したウインドウ(windowNumで指定する)の座標での位置

( unsigned int )flags

YES/NO

( NSTimeInterval )time

イベントが発生した時間

( int )windowNum

ウインドウ番号

( NSGraphicsContext * )context

グラフィックコンテキスト

( int )eventNumber

イベント番号

( int )clickNumber

マウスクリックの数。

( float )pressure

圧力 0.0〜1.0の値。
タブレットのような入力装置のために使われるマウスイベント。
感圧式でなければ値は0.0か1.0でなければならない。

フレームワーク

ApplicationKit

クラス

NSEvent

Class Methods

使用可能

10.0

参照

- clickCount
- eventNumber
- pressure

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSEvent *ev = [NSEvent mouseEventWithType:NSLeftMouseDown
                            location:NSMakePoint(200,200)
                            modifierFlags:nil
                            timestamp:nil
                            windowNumber:[[sender window] windowNumber]
                            context:nil
                            eventNumber:nil
                            clickCount:1
                            pressure:nil
                            ];

[NSApp sendEvent:ev];

}

@end