macOS/iOS API解説

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

目次

orderFrontRegardless

INDEX>AppKit> NSWindow

アプリケーションがアクティブでなくてもウインドウを前面に持ってきます

Objective-C

- (void)orderFrontRegardless

Swift

func orderFrontRegardless()

解説

アプリケーションがアクティブでなくてもウインドウを前面に持ってきます。
通常このメソッドは使いませんが、別のアプリケーションから呼び出されてウインドウを表示したいときなどに使われます。

返り値

なし

引数

なし

フレームワーク

ApplicationKit

クラス

NSWindow

使用可能

10.0

参照

- orderFront:
- level

更新時のバージョン

OS X 10.10

関連記事(外部サイト)

例文

#import "Controller.h"

@implementation Controller

- (IBAction)pushButton:(id)sender
{
    [myWindow orderBack:sender];
    [myWindow orderFrontRegardless];
    }
@end

Swift

    //NSWindow orderFront
    func buttonAction074(sender: AnyObject){
        var aWindow : NSWindow = (sender as NSButton).window!
        aWindow.orderFront(self)
    }
    @IBAction func function074(sender: AnyObject) {
        var theWindow1 : NSWindow = NSWindow(contentRect: NSMakeRect(100.0, 100.0, 300, 200), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false)
        windowArray.addObject(theWindow1) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄
        theWindow1.title = "ウインドウタイトル1"//タイトル設定
        theWindow1.orderFront(self)//前面に
        theWindow1.makeKeyAndOrderFront(self)//表示
        //ボタンを作成
        var theButton1 : NSButton = NSButton(frame: NSMakeRect(100.0, 2.0, 100.0, 30.0))
        theButton1.title = "Action"
        theButton1.bezelStyle = NSBezelStyle.RoundedBezelStyle
        theButton1.action = Selector("buttonAction074:")
        theButton1.target = self
        theWindow1.contentView.addSubview(theButton1)
        
        var textField1 : NSTextField = NSTextField(frame: NSMakeRect(100.0, 100.0, 100.0, 30.0))
        theWindow1.contentView.addSubview(textField1)
        
        var theWindow2 : NSWindow = NSWindow(contentRect: NSMakeRect(140.0, 140.0, 300, 200), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false)
        windowArray.addObject(theWindow2) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄
        theWindow2.title = "ウインドウタイトル2"//タイトル設定
        theWindow2.orderFront(self)//前面に
        theWindow2.makeKeyAndOrderFront(self)//表示
        //ボタンを作成
        var theButton2 : NSButton = NSButton(frame: NSMakeRect(100.0, 2.0, 100.0, 30.0))
        theButton2.title = "Action"
        theButton2.bezelStyle = NSBezelStyle.RoundedBezelStyle
        theButton2.action = Selector("buttonAction074:")
        theButton2.target = self
        theWindow2.contentView.addSubview(theButton2)
        
        var textField2 : NSTextField = NSTextField(frame: NSMakeRect(100.0, 100.0, 100.0, 30.0))
        theWindow2.contentView.addSubview(textField2)
        
        var theWindow3 : NSWindow = NSWindow(contentRect: NSMakeRect(180.0, 180.0, 300, 200), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false)
        windowArray.addObject(theWindow3) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄
        theWindow3.title = "ウインドウタイトル3"//タイトル設定
        theWindow3.orderFront(self)//前面に
        theWindow3.makeKeyAndOrderFront(self)//表示
        //ボタンを作成
        var theButton3 : NSButton = NSButton(frame: NSMakeRect(100.0, 2.0, 100.0, 30.0))
        theButton3.title = "Action"
        theButton3.bezelStyle = NSBezelStyle.RoundedBezelStyle
        theButton3.action = Selector("buttonAction074:")
        theButton3.target = self
        theWindow3.contentView.addSubview(theButton3)
        
        var textField3 : NSTextField = NSTextField(frame: NSMakeRect(100.0, 100.0, 100.0, 30.0))
        theWindow3.contentView.addSubview(textField3)
    }