Вопрос

Я хочу отобразить 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