@@ -1770,6 +1770,64 @@ void NSBeginInformationalAlertSheet(NSString *title,
17701770 NSReleaseAlertPanel (panel);
17711771}
17721772
1773+ // Synchronous sheet-aware alert. If docWindow is nil, fall back to
1774+ // NSRunAlertPanel which shows a modal alert. Otherwise display a sheet
1775+ // attached to docWindow and run a modal loop until it completes.
1776+ NSInteger
1777+ NSRunAlertPanelRelativeToWindow (NSString *title,
1778+ NSString *msg,
1779+ NSString *defaultButton,
1780+ NSString *alternateButton,
1781+ NSString *otherButton,
1782+ NSWindow *docWindow, ...)
1783+ {
1784+ va_list ap;
1785+ NSString *message = nil ;
1786+ GSAlertPanel *panel = nil ;
1787+ NSInteger result = 0 ;
1788+
1789+ va_start (ap, docWindow);
1790+ message = [NSString stringWithFormat: msg arguments: ap];
1791+ va_end (ap);
1792+
1793+ // Set the default button...
1794+ if (defaultButton == nil )
1795+ {
1796+ defaultButton = @" OK" ;
1797+ }
1798+
1799+ // Show a panel or a sheet depending on if we have a window...
1800+ if (docWindow == nil )
1801+ {
1802+ panel = getSomePanel (&standardAlertPanel,
1803+ defaultTitle,
1804+ title,
1805+ message,
1806+ defaultButton, alternateButton, otherButton);
1807+
1808+ result = [panel runModal ];
1809+ }
1810+ else
1811+ {
1812+ panel = getSomeSheet (&informationalAlertPanel,
1813+ defaultTitle,
1814+ title,
1815+ message,
1816+ defaultButton, alternateButton, otherButton);
1817+
1818+ [NSApp beginSheet: panel
1819+ modalForWindow: docWindow
1820+ modalDelegate: nil
1821+ didEndSelector: NULL
1822+ contextInfo: NULL ];
1823+
1824+ result = [panel result ];
1825+ }
1826+
1827+ NSReleaseAlertPanel (panel);
1828+ return result;
1829+ }
1830+
17731831
17741832@implementation NSAlert
17751833
0 commit comments