2017-06-27 61 views
1

我正在嘗試編寫一個應用程序,該應用程序在單擊按鈕後應該保持運行,因此我想將其最小化。我有theWindow連接到佔位在Xcode mac osx AppleScript應用程序(AppleScriptObjC)中,我最小化主應用程序窗口的命令是什麼?

property theWindow : missing value 

我已經嘗試了應用程序的主窗口:

theWindow's performMiniaturize() 
theWindow's miniaturize() 

但我不斷收到消息:

[NSView performMiniaturize]: unrecognized selector sent to instance 0x608000120280 (error -10000)

回答

0

-[NSWindow miniaturize:]

theWindow's miniaturize: me 

這就是說,你爲什麼不只是關閉窗口,如果/根據需要重新打開以後呢? (請確保您的應用程序未配置窗口關閉時,當然要自動退出。)

+0

。這樣做的竅門,並感謝您的建議,以優化應用程序。 太棒了。 – Belerofonte

0

微型化()是在ASOC正確。但是你在一個視圖(NSView)上調用它,而不是一個窗口 - 這就是錯誤所說的。

爲了讓你可以爬上視圖hirarchy這樣

set window to view's superview() 

其中變量視圖是你錯誤地稱爲窗口的窗口。但是請注意:只有當下一個級別是窗口而不是另一個NSView時,這纔會起作用。

或者你可以得到這樣的主窗口:

if exists (1st window whose value of attribute "AXMain" is true) then tell (1st window whose value of attribute "AXMain" is true) to miniaturize() 
+0

建議的命令會導致編譯錯誤: 錯誤:預期「」卻發現「「」(-2741) – Belerofonte

相關問題