Small app does not get keyboard events for alert sheet
Small app does not get keyboard events for alert sheet
- Subject: Small app does not get keyboard events for alert sheet
- From: Tomas Kolar <email@hidden>
- Date: Mon, 23 Mar 2009 07:03:34 +0100
Hello all,
we have problem with a minimalistic application that opens standard
alert sheet. The code looks like this:
int main(int ac, char *av[])
{
NSApplication *app=[NSApplication sharedApplication]; // tried to
send activateIgnoringOtherApps:YES, in vain
NSRect frame=NSMakeRect(100,100,600,400);
NSWindow *win=[[NSWindow alloc] initWithContentRect:frame
styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained
defer:NO];
[win setAlphaValue:0]; // we don't want to show the window--it's just
the sheet "base"
[win setLevel:NSNormalWindowLevel+1];
[win orderFrontRegardless];
NSBeginAlertSheet(@"...", nil, nil, nil, win, nil, NULL, NULL, NULL,
@"...");
[app runModalForWindow:[win attachedSheet]];
return 0;
}
The application correctly opens alert sheet but does not get any
keyboard actions nor events — they are still sent to previous open
app. Nevertheless, sheet could be closed by mouse. We also try to use
NSRunAlertPanel with the same output, so we suspect the problem is on
the Window Server side (or between WS and our app).
This did not help either:
@implementation Delegate:NSObject
+(void)applicationDidFinishLaunching:(NSNotification*)dummy
{
NSRect frame=NSMakeRect(100,100,600,400);
NSWindow *win=[[NSWindow alloc] initWithContentRect:frame
styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained
defer:NO];
[win setAlphaValue:0]; // we don't want to show the window--it's just
the sheet "base"
[win setLevel:NSNormalWindowLevel+1];
[win orderFrontRegardless];
[NSApp activateIgnoringOtherApps:YES];
NSBeginAlertSheet(@"...", nil, nil, nil, win, self, NULL,
@selector(done), NULL, @"...");
}
+(void)done
{
[NSApp terminate:self];
}
@end
int main(int ac,char *av[])
{
NSApplication *app=[NSApplication sharedApplication];
[app setDelegate:[Delegate class]];
[app run];
return 0;
}
Does anyone know, where could be problem or what do we wrong?
Thanks!
Tom
--
Tomáš Kolář
email@hidden
Audiffex - Audio Effects & Applications
www.audiffex.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden