Re: NSPanel is freezing
Re: NSPanel is freezing
- Subject: Re: NSPanel is freezing
- From: Matt Jaffa <email@hidden>
- Date: Sun, 7 Nov 2004 16:47:51 -0700
I am having it run as a Modal so that I can have the panel time out
after 40 seconds, that is why you see the sleeping of every second in
that for loop,
and after it gets to 40 ish seconds it cancels the modal, and breaks
out and closes the panel,
and the two action methods just close it right away.
I have a seperate thread that goes through a loop and then looks at a
queue to see if there is something to do, if there is it pops this
panel up and gets the input back.
Matt
On Nov 7, 2004, at 3:43 PM, j o a r wrote:
To me it looks a bit overly complicated, and also a bit weird. You
only process events once per second? Anyway, a couple of questions:
Do you have a standard NSRunLoop running?
Why not use a standard "runModalForWindow:"?
Why run modal at all, if it's the only GUI available to the user?
j o a r
On 2004-11-07, at 23.12, Matt Jaffa wrote:
Ok here is the code:
This is where it displays it:
[displayAlertPanel setLevel:NSPopUpMenuWindowLevel];
//[displayAlertPanel setLevel:NSScreenSaverWindowLevel];
[displayAlertPanel setDelegate:self];
[displayAlertPanel makeKeyAndOrderFront:self];
[seconds setStringValue:@"40"];
printf("comes here----1\n");
//[NSApp activateIgnoringOtherApps:YES];
session = [NSApp beginModalSessionForWindow:displayAlertPanel];
printf("comes here----2\n");
int dontdorest = 1;
NSDate *startDate = [NSDate date];
NSDate *currentDate;
buttonpressed = 0;
[dataSending setString:@""];
NSString * thestring = @"";
unsigned char * buff = point->buffer;
int length = point->buf_len;
for (;;) {
usleep(1000000);
currentDate = [NSDate date];
NSTimeInterval interval = [currentDate
timeIntervalSinceDate:startDate];
printf("Interval: %f\n", interval);
int final = 40 - (int)interval;
[seconds setStringValue:[NSString stringWithFormat:@"%d", final]];
if(final < 15) {
[seconds setTextColor:[NSColor redColor]];
}
if ([NSApp runModalSession:session] != NSRunContinuesResponse) {
dontdorest = 0;
break;
}
if(interval > 40) {
[NSApp stopModal];
buttonpressed = 1;
[displayAlertPanel close];
break;
}
}
[NSApp endModalSession:session];
//[NSApp runModalForWindow:displayAlertPanel];
//[displayAlertPanel close];
if(dontdorest) {
printf("was ended by timeout\n");
} else {
printf("was ended by buttonp\n");
}
And here is where the action buttons are:
- (IBAction)allowAction:(id)sender
{
printf("allow Action pressed\n");
buttonpressed = 1;
[NSApp stopModal];
[displayAlertPanel close];
}
- (IBAction)denyAction:(id)sender
{
printf("deny Action pressed \n");
buttonpressed = 1;
[NSApp stopModal];
[displayAlertPanel close];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden