Re: [Pyobjc-dev] applicationShouldOpenUntitledFile_
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2003-02-02 17:36:35
|
On Sunday, Feb 2, 2003, at 12:26 US/Eastern, Etienne Posthumus wrote: > On Sunday, Feb 2, 2003, at 08:22 Europe/Amsterdam, Mitch Chapman wrote: >> On Saturday, February 1, 2003, at 11:00 PM, bb...@ma... wrote: >>> Very easy fix and not at all obvious. The problem is that there is >>> no way for the bridge to know that your implementation of the method >>> should return BOOL. So, you either have to tell the bridge that >>> your method returns a BOOL through the use of the objc.selector() >>> function or, better yet, declare that your class implements the >>> informal NSApplication delegate protocol. > >> Hm... I think the project template already did this for me. >> (BTW thanks for including the project templates -- way cool.) >> Here's the relevant code, showing the class declaration provided by >> the template: > >> The log message is showing up in the PB Run window, right about the >> time the unwanted Untitled document appears. > > In trying to make a delegate for a window responding to > windowShouldClose, I can also not get it to NOT close the window even > if I have only one statement in the method: > return NO > > Could this be related to the above behaviour? Very likely. The problem is that there is no way for the bridge to know that your method should return a BOOL unless you use objc.selector() or declare your object to be an NSWindowDelegate. I was just looking into this and there appears to be a bug that was introduced sometime recently. The following code used to work, now it doesn't. I'm not sure why: # create ObjC classes as defined in MainMenu.nib NibClassBuilder.extractClasses("MainMenu") class MyAppDelegate(AutoBaseClass, NSApplicationDelegate): def applicationShouldOpenUntitledFile_(self, sender): # return NO if you don't want untitled document to be opened on app launch return NO |