In my spare time, I’m working on a testbed app for MacOS in preparation for my first real MacOS app that is fast approaching. I’ve gotten many things working so far, including DataAbstract, tableviews, and more, but there is one problem that still has me puzzled.
in the attached project, I have two window controllers. In the first window controller, I have a button that displays the 2nd windowcontroller as a sheet. On the sheet, I have a single button which tries to close the sheet. in reality, when I click on the sheet’s button, it doesn’t call my IBAction method which is hooked into the button.
Can someone take a closer look at the xibs and let me know what I’ve obviously forgotten, or connected wrong, because I can’t even show an NSLog line in the button click method. its not being called.
While waiting on a reply, I went on and starting filling out the modal sheet I describe above. I added an NSTextField with which I need to do a DA lookup on, so I did some reading and tried to implement the delegate method controlTextDidChange(obj : NSNotification). I added this method to the windowcontroller, and set the NSTextField’s delegate to File’s Owner. I added some code to this method in the windowcontroller, but to my surprise, this method/event is NOT being called when the text does in fact change in the NSTextField.
From all the examples I saw, I shouldn’t need to do anything more. Or do I?
that said, just looked at your project, and it beats me; all looks good, this SHOULD work. yet I too see, the handler isn’t being called. very weird. The code looks good, and the association in the xib file looks fine, too.
Seems like that could be the same issue. but I can’t for the life of me figure to why it would fail. I checked the binary too, the method is named properly and everything…
unrelated, though that didn’t fix it, you did misspell didEndSheet:returnCode:contextInfo: vs didSheetEnd(sheet: NSWindow) returnCode(returnCode: Integer) contextInfo(contextInfo: ^Void);
notice didEndSheet / didSheetEnd
but fixing that didn’t help, as it doesn’t even get that far…
you omitted the strongSelf part of my sample code. whats happen ing is that right after:
var NewJob := new AddJobWindow;
NewJob.showForWindow(self.window);
the NewJob variable goes out of scope and because no-one else is holding on to your window controller, kit gets released. the windows stays up, up it now no longer has a controller (since the windows keeps a weak reference only), Sao by there time you click cancel, there’s no object to click cancel on.
add a var strongSelf: AddJobWindow; field to the window controller, set it in show:
I have one request. If at all possible, could someone on your team put together a sample app that shows how to write a cross platform or shared project using data abstract for both windows.net and MacOS? For some reason I’m having a hard time wrapping my head around how to implement a shared project like that. It would be extremely helpful. Thanks much