+
+- (void)setImplementation: (wxDialog *)dialog
+{
+ impl = dialog;
+}
+
+- (BOOL)finished
+{
+ return sheetFinished;
+}
+
+- (int)code
+{
+ return resultCode;
+}
+
+- (void)waitForSheetToFinish
+{
+ while (!sheetFinished)
+ {
+ wxSafeYield();
+ }
+}
+
+- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+{
+ wxUnusedVar(contextInfo);
+ resultCode = returnCode;
+ sheetFinished = YES;
+ // NSAlerts don't need nor respond to orderOut
+ if ([sheet respondsToSelector:@selector(orderOut:)])
+ [sheet orderOut: self];
+
+ if (impl)
+ impl->ModalFinishedCallback(sheet, returnCode);
+}
+@end
+
+// here we subclass NSApplication, for the purpose of being able to override sendEvent.
+@interface wxNSApplication : NSApplication
+{
+}
+
+- (void)sendEvent:(NSEvent *)anEvent;
+
+@end
+
+@implementation wxNSApplication
+
+/* This is needed because otherwise we don't receive any key-up events for command-key
+ combinations (an AppKit bug, apparently) */
+- (void)sendEvent:(NSEvent *)anEvent
+{
+ if ([anEvent type] == NSKeyUp && ([anEvent modifierFlags] & NSCommandKeyMask))
+ [[self keyWindow] sendEvent:anEvent];
+ else [super sendEvent:anEvent];
+}
+