macOS/iOS API解説

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

目次

setWorksWhenModal:

モーダルウインドウがあるときでもイベントを受け取るかをセットします
-(void)setWorksWhenModal:(BOOL)flag:

解説

モーダルウインドウがあるときでもイベントを受け取るかをセットします。
YESをセットすると、モーダルウインドウがあってもイベント(キーボード入力やマウスクリック)を受け取ります。
受け取らせたくない場合はNOをセットします。

返り値

( void )

なし

引数

( BOOL )flag

YES/NO

フレームワーク

ApplicationKit

クラス

NSPanel

Instance Methods

使用可能

10.0

参照

- worksWhenModal
- runModalForWindow:(NSApplication)
-runModalSession:(NSApplication)

例文

#import "Controller.h"

@implementation Controller

- (IBAction)pushButton:(id)sender
{
NSOpenPanel *opanel = [NSOpenPanel openPanel];
NSArray *fileTypes = [NSArray arrayWithObjects:@"jpg",@"pdf",@"txt",@"'JPEG'",@"'TEXT'",nil];
int opRet;
 [myWindow setWorksWhenModal:YES];
opRet = [opanel runModalForDirectory:NSHomeDirectory()
    file:nil
    types:fileTypes
    ];
if (opRet == NSOKButton){
NSLog([opanel filename]);
[info setStringValue:[opanel filename]];
}else{
NSLog(@"Cansel");
}
}
-(void)didEndSaveSheet:(NSSavePanel *)savePanel returnCode:(int)returnCode conextInfo:(void *)contextInfo
{
}
@end