Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't click on StandardAlert button



On 2 nov. 07, at 17:45, Gary L. Wade wrote:

Behavior like that happens in applications, at best, if you launch the alert
from a thread that's not the main thread.

The call does happen in the main thread. Compiling the single-function program I gave as example also has only one thread, and exhibits the same behavior: it is impossible to click buttons.


Also, you need to make your message and explanation strings to be Pascal
strings, not C-strings. Pascal strings are explicitly unsigned character
arrays (the zeroth byte goes from 0 to 255 for the length of the string), so
you wouldn't need to do the typecast you're doing in your call. If you're not
familiar with that method of declaration, this is how it would be:

Thanks for this information!

On 2 nov. 07, at 17:57, Eric Schlegel wrote:

J.P., does your app use the bundled directory format (YourApp.app/ Contents/MacOS/YourApp contains your binary), or are you just building a single unbundled binary file? The symptoms you're describing are typical of an unbundled app. Mac OS X requires an app to be bundled for it to get the normal process management behavior for a GUI app.

You're right, Eric: the app was unbundled. It is now bundled and correctly lets me click the buttons! Thanks a lot!


If your app is unbundled, you can make it behave like a GUI app by calling TransformProcessType (Processes.h) to make it foreground- capable

I can also confirm that adding these two lines before calling StandardAlert also works:


	ProcessSerialNumber me = { 0, kCurrentProcess };
	TransformProcessType(&me, kProcessTransformToForegroundApplication);

The completed program that works is thus:

#include <Carbon/Carbon.h>
int main (int argc, char * const argv[]) {
ProcessSerialNumber me = { 0, kCurrentProcess };
TransformProcessType(&me, kProcessTransformToForegroundApplication);
SInt16 out;
unsigned char *alert1 = "\pLicence file cannot be found.";
unsigned char *alert2 = "\pPlease obtain a licence file and run the program again.";
StandardAlert (kAlertNoteAlert,
alert1,
alert2,
NULL,
&out);
printf("response: %i\n", 5, out);
return 0;
}


On 2 nov. 07, at 18:03, Jack Small wrote:

I would probably use CFUserNotification APIs here instead of StandardAlert if at all possible. Or, you might want to consider rewriting your app in Cocoa.

Yep. The problem is that it is an old cross-platform app written with the YAAF framework. I am actually just changing part of the Mac- specific part of YAAF to keep it cross-platform for now, until we can compile Cocoa for Win32 :-)


Problem solved; thanks all for your very valuable help.

J.P.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Can't click on StandardAlert button (From: "J.P. Pellet" <email@hidden>)
 >Re: Can't click on StandardAlert button (From: "Gary L. Wade" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.