Positng this question here for lack of a better place to put it.
Here is the code I'm messing with:
Code:
#include<Carbon/Carbon.h>
int main(int ArgC, char **ArgV)
{
Rect rPos;
WindowRef Handle;
EventTypeSpec etsEventTypes[2];
rPos.top = 200;
rPos.left = 300;
rPos.bottom = 400;
rPos.right = 500;
//Create the window
CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes |
kWindowStandardHandlerAttribute, &rPos, &Handle);
//Show the window
ShowWindow(Handle);
RunApplicationEventLoop();
//Remove the winow
DisposeWindow(Handle);
return 0;
}
And I compile it with:
Code:
gcc OSXGUI.c -framework Carbon
The code does create a window. Te problem is the window won't respond to anything.
According to the API docs, the call to RunApplicationEventLoop() is supposed to install the default event handler to the window. That default handler is supposed to handle the basic requests; maximize, minimize, resize, and move. Except its not doing that. The window will maximize and minimize, but not move or resize.
Am I compiling it wrong (It seems to want to be a console app as opposed to a GUI app)? Or is there some other issue with my code?
My guess is the event loop that is created is for the thread rather than the application, since if I install my own event handler it never recieves anything. But I just don't know, and the documentation Apple has doesn't cover windows that aren't made from NIB's very well.
[EDIT]
Well even if its creating an event loop for the thread that shouldn't matter. I replaced the call to RunApplicationEventLoop() with my own event loop:
Code:
eventRecord Event;
while(1)
{
WaitNextEvent(everyEvent, &Event, (unsigned int)-1, NULL);
printf("Got an event!\n");
}
and the loop was given events for the window. I didn't see any events for move or size requests though.
[/EDIT]