質問

基本的にはアクセサリビューでNSALERTを表示したいです。アクセサリビューには:

1)必須の内容を表示するためのNSTEXVIEW

2)NSTextViewが付いている開示ボタン

開示ボタンは、2番目のNStextViewを隠して表示する必要があります。ただし、同時に、NSalertダイアログが収容され、コンテンツに適合するようにサイズ変更されます。 Cocoaの保存ダイアログには、基本的にこれを行う開示ボタンがあり、NSalertと同じ機能が必要です。 提案?

役に立ちましたか?

解決

Here you go:

1) NSAlert has a window property. Hence use that.

2) Create a custom accessory view containing two NSTextView's and a disclosure triangle

3) Set this custom view as accessory view of NSAlert

4) Before displaying the alert, set the window property of NSAlert in your custom view (This way you will have access to NSAlert's window when you click disclosure triangle)

5) Add target for the disclosure button event and save the state (expanded/collapsed)

6) In the event for disclosure triangle click: Use NSAlert's saved window frame to adjust the height, size and width of NSAlert.

7) Important here is to note that - when you adjust the height, NSAlert grows from top hence you will be required to move the "origin" accordingly.

Hope this helps :). I had to spend entire weekend to figure out how to do this :D. BTW, just out of curiosity which project or company are you working on?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top