문제

기본적으로 액세서리 뷰와 함께 NSALERT를 표시하고 싶습니다.액세서리 뷰는 다음과 같습니다.

1) 필수 내용 표시를위한 nstexview

2) NSTextView가있는 공개 버튼

공개 버튼은 두 번째 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