• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Small app does not get keyboard events for alert sheet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Small app does not get keyboard events for alert sheet
      • From: Ken Thomases <email@hidden>
  • Prev by Date: IB instantiating objects
  • Next by Date: How to implement quick-playing and slow-playing of sound file?
  • Previous by thread: Re: IB instantiating objects
  • Next by thread: Re: Small app does not get keyboard events for alert sheet
  • Index(es):
    • Date
    • Thread