An old application that I am updating has several confirmation alerts
for hazardous operations. The alert format violated Apple's interface
guidelines, and it took me a surprisingly long time to fix.
Just in case it might be useful to someone else, here is the result.
'---------------
/*
Return _zTrue if user clicks the left-hand (action) button, else
_false
*/
local mode
local fn ConfirmDangerousAction( message as Str255, explanation as
Str255, actionBtnTitle as Str255 )
'~'1
dim as AlertStdAlertParamRec paramRec
dim as Str255 defaultBtnTitle
dim as OSErr ignore
dim as SInt16 @ itemHit
dim as Boolean confirmed
BlockZero( @paramRec, sizeof( paramRec ) )
defaultBtnTitle = "Cancel"
paramRec.defaultText = @defaultBtnTitle
paramRec.otherText = @actionBtnTitle
paramRec.defaultButton = 1
ignore = fn StandardAlert( _kAlertCautionAlert, message, explanation,
@paramRec, @itemHit )
confirmed = ( itemHit == _kAlertStdAlertOtherButton )
end fn = confirmed
dim as Boolean goAhead
goAhead = fn ConfirmDangerousAction( "Are you sure you want to erase
the disk?",¬
"It could take a while", "Erase Disk" )
'---------------
Robert P.