SSブログ

NSWindowを非表示にする [AppleScript辞書はつくれるか?]

当ブログの検索ワードに、
window1.png

NSWindowを非表示にするという検索が入っていたので、ちょっと調べてみた。

NSWindowを非表示にするということを調べたかったのか、hiddenとキーワードも見えます。
けれど、hiddenでは非表示にはできないようです。
そして、Visibleを使っても消えなかった。...というか使えなかった。

とりあえず、ちょっとめんどくさいけどこんな方法はいかが?

該当Window(NSWindow)の『Show the Bindings inspector』から
window3.png
window2.png

ParametersのVisibleをたどり
『Bind to 』を”Delegate”に変更しチェックを入れる。
そして、"Model Key Path"の項目を(仮に)flgに変更(※)

スクリプトに、

script AppDelegate

property parent : class "NSObject"


    property flg : true

    on button1_(sender)

        set my flg to false --非表示

        delay 1

        set my flg to true --再表示

    end button1_


-- IBOutlets

property theWindow : missing value


on applicationWillFinishLaunching_(aNotification)

-- Insert code here to initialize your application before any files are opened 

end applicationWillFinishLaunching_

    (*

    on applicationShouldTerminateAfterLastWindowClosed_(sender)

        return true

    end applicationShouldTerminateAfterLastWindowClosed_

    *)

on applicationShouldTerminate_(sender)

-- Insert code here to do any housekeeping before your application quits 

return current application's NSTerminateNow

end applicationShouldTerminate_


end script



上記ののついてる部分を追加。
ボタンアクションは説明しないけどリンクをつないでね。

実行すると、ウインドウが消えて、1秒後に表示されるはずです。

ちなみに、

   on applicationShouldTerminateAfterLastWindowClosed_(sender)

        return true

   end applicationShouldTerminateAfterLastWindowClosed_

という部分が生きてると、ウインドウが閉じた瞬間にアプリケーションが終了してしまうので外しておこう。


どうでしょう?

かなり苦しいやり方ですが、他に何かあるかな?


(※)本文中に『(仮に)flgに変更』という書き方をしてますが、この変数はなんでも良いのです。

なにかわかりやすい他単語に変更しても良いです。




nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:パソコン・インターネット

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。