> On 2016 Aug 22, at 23:04, Andreas Falkenhahn <andr...@falkenhahn.com> wrote:
>
> On 22.08.2016 at 15:49 dangerwillrobinsondan...@gmail.com wrote:
>
>
>>> On Aug 22, 2016, at 10:26 PM, Andreas Falkenhahn <andr...@falkenhahn.com>
>>> wrote:
>
>>> Does anybody have an idea
>>> what could cause this behaviour on 10.6 and how I can fix this?
>> http://bfy.tw/7Kcc
>> there is a great resource here.
>
> You really think I didn't Google before asking? I certainly did, but
> so far I haven't found anything that could help me here. If you have
> anything more than just a Google search for "NSAlert 10.6", please
> elaborate... (or send a link)
>
> --
> Best regards,
> Andreas Falkenhahn mailto:andr...@falkenhahn.com
>
However you have not really shown any code at all.
So we do not know if you tested the returnCode from runModal against
NSAlertFirstButtonReturn, NSAlertSecondButtonReturn, NSAlertThirdButtonReturn
or all or none of these.
Without knowing more than the URL you shared saying you implemented what was in
that document it's really hard to know what you might be doing wrong.
You might try the delegate-based sheet methods to run as described in the
NSAlert class reference. (be sure to set your delegate and implement the
callbacks)
You might try the completion handler sheet method. It's super compact.
For runModal, you do it inline, the delegate gets no callback unless you're
using a help button.
// in simple test app.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
NSAlert *alert = [NSAlert new];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert setInformativeText:@"Informative text here."];
[alert setDelegate:self]; // Does nothing here unless we had a help
button, because this is app modal.
NSInteger returnCode = [alert runModal];
NSLog(@"%@ %@ alert=%@ returnCode=%ld", self,
NSStringFromSelector(_cmd), alert, returnCode);
if (returnCode == NSAlertFirstButtonReturn) {
NSLog(@"first button return %ld", returnCode);
} else if (returnCode == NSAlertSecondButtonReturn) {
NSLog(@"second button return");
} else if (returnCode == NSAlertThirdButtonReturn) {
NSLog(@"third button return");
} else {
NSLog(@"unknown button return");
}
}
I sure don't have anything that runs 10.6 so I couldn't even test it there, but
I see no indication in the NSAlert Class Reference document history that would
say this should not work.
You can of course also use a switch-case flow here instead of if-else.
Remember runModal is app-modal, so it doesn't return control to anything about
the app until a button is pressed.
Really, you should consider using the delegate based sheet methods, assuming
your app as a scripting language tool is document centric by design, wouldn't
you want alerts to be more contextual?
App modal sheets are also possible.
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingAppModalDialogs.html
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com