discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPanel and modal run loop


From: Riccardo Mottola
Subject: NSPanel and modal run loop
Date: Wed, 12 Jun 2013 09:39:11 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0 SeaMonkey/2.17.1

Hi,

I have a simple controller which should display a modal panel, decoded from a nib/gorm interface file (for reference GetNameController.m in FTP in GAP).

the controller has this method:
-(NSInteger)runAsModal
{
  NSInteger result;

  [panel makeFirstResponder: textField];
  result = [NSApp runModalForWindow: panel];
  return result;
}

and each ok/cancel button does:
-(IBAction)cancelPressed:(id)sender
{
  [panel close];
  [NSApp stopModalWithCode: NSAlertAlternateReturn];
}

looks simple and it should work, doesn't it? Well, Almost.

On the mac, the following may happen: the user hits the "close" button of the window or hits "esc". In that case, the panel disappears, but the app is still in the modal run loop (all interfaces disabled). The only thing I can do is terminate the application. I guess instead that I should be able to trap that closure and return either NSAlertAlternateReturn or NSAlertErrorReturn. What do you think? and how? I tried to implement "performClose" but it doesn't get called in the delegate.

Thus I think my code is somehow incorrect, however on GNUstep I notice
1) it works? I can close the panel without problems
2) esc doesn't close the panel, even if the Apple doc says it should.

"If a panel is the key window and has a close button, it closes itself when the user presses the Escape key."

Riccardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]