Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSAlert destructive button

As Big Sur came onto our Macs I noticed that destructive button's text in NSAlert controller are colored in red as shown in picture.

An example from the Apple's Message app

I wasn't able to find a way to bring this feature in my app.

Using the standard addButton(withTitle:) method we haven't any way to set its intent (such as default, cancel or destructive).

Can you give me any hint?

Thanks

like image 406
Altair Jones Avatar asked Oct 15 '25 14:10

Altair Jones


1 Answers

Set the property hasDestructiveAction of the button to true . This property is new in Big Sur.

Source: AppKit Release Notes for macOS Big Sur 11

like image 119
vadian Avatar answered Oct 17 '25 10:10

vadian