Newbie problem with MacOS app

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.

thanks

Alan

Archive.zip (5.6 MB)

I’ll have a look in the am.

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?

alan

My apologies, stressful day. looking now.

You seem to be having a lot of those lately!

:wink: par of the course…

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. :frowning:

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…

Well crap. That’s good…but bad, I guess. What’s the next step?

Not sure. let me have a look at it with a fresh mind, tomorrow. Has to be something silly.

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…

Also odd, the code, added to windowsDidLoad works ok, prints what I expect and DOES call the event ok:

  NSLog('OKButton %@', OKButton);
  NSLog('OKButton.action %@', NSStringFromSelector(OKButton.action));
  NSLog('OKButton.target %@', OKButton.target);
  OKButton.target.performSelector(OKButton.action) withObject("test");

That is odd

Shouldn’t the compiler catch this??

SheetDidEnd vs didSheetEnd??

Found the problem.

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:

    parentwindow := aWindow;
    strongSelf := self;
    NSApp.beginSheet(...

and clear it as the last thing in sheetDidEnd:

    strongSelf := nil;

Let me go try now…

Thanks much! Now this all makes sense. Welcome to OS X, Alan.

1 Like

Everything is working now. Thanks again, and I hope you have a stress-free weekend.

1 Like

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

I think you just need to stick to the classes in rtl2 and not use anything platform specific.

Do you also want to use a database of some kind ?

Yeah using a data abstract server