Re: [Pyobjc-dev] Returning BOOLs to Cocoa
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-07-22 17:57:42
|
On Tuesday, 22 July, 2003, at 18:31, Bob Swerdlow wrote: > I seem to be missing something about BOOLs returned from python members > called for Cocoa delegates. :-( > > I implemented a Cocoa delegate for my window to support > windowShouldClose_( ) since I need to do some checking of user input > before > I allow the window to close. However, no matter what I return, the > window > always closes. > > Originally, I just used: > return 0 > but I also tried: > return objc.NO > > I added a print statement for when the code returns objc.NO and it > printed: > returning FALSE > > What is the proper value to return so that Cocoa knows I don't want it > to go > on? Returninging 0, False or objc.NO should work. Are you using PyObjC 1.0b1? If you're using the 0.9 release, you have to tell the bridge that you intent implement a window delegate. I added 'self.tableView.window().addDelegate_(self)' in 'awakeFromNib' and the following method to the TableView example and that works as expected. def windowShouldClose_(self, sender): """ Window won't close """ print "Should Close?" return 0 Ronald |