iDevGames Forums
Standard C++ Carbon Application Template - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Standard C++ Carbon Application Template (/thread-1078.html)



Standard C++ Carbon Application Template - AdrianM - Jun 28, 2009 02:12 PM

I want to create a simple splash window and use carbon for that. I never created windows on the mac but i did quite a lot of win32 api programming. Using the template made by xcode i want to catch events like mousedown. I tried doing it like this, but it does not seem to work, "mouse down " is never printed on the screen, and all there is are two numbers, always the same, at every mouse click, resize etc:

Boolean
MainWindow::HandleCommand( const HICommandExtended& inCommand )
{
switch ( inCommand.commandID )
{
// Add your own command-handling cases here

case kEventWindowBoundsChanged:
printf("mouse down %d\n", inCommand.commandID);
return true;

default:
printf("d=%d %d\n", inCommand.commandID, inCommand.attributes);
return false;
}
}

So, what is the right way to do it?


Standard C++ Carbon Application Template - Ingemar - Jun 28, 2009 02:55 PM

AdrianM Wrote:I want to create a simple splash window and use carbon for that. I never created windows on the mac but i did quite a lot of win32 api programming. Using the template made by xcode i want to catch events like mousedown. I tried doing it like this, but it does not seem to work, "mouse down " is never printed on the screen, and all there is are two numbers, always the same, at every mouse click, resize etc:

Boolean
MainWindow::HandleCommand( const HICommandExtended& inCommand )
{
switch ( inCommand.commandID )
{
// Add your own command-handling cases here

case kEventWindowBoundsChanged:
printf("mouse down %d\n", inCommand.commandID);
return true;

default:
printf("d=%d %d\n", inCommand.commandID, inCommand.attributes);
return false;
}
}

So, what is the right way to do it?

Well, to begin with, printf goes to stdout, that is the console if available, usually to nowhere.

Just like in Win32, you need a port/context to draw in, and draw the text in that.

Also, I can't see the mouse down event being handled. You just handle the event for the window size being changed. Maybe you need a better template to work from? There is plenty of code around that does what you need.


Standard C++ Carbon Application Template - AdrianM - Jun 29, 2009 04:51 AM

Ingemar Wrote:Well, to begin with, printf goes to stdout, that is the console if available, usually to nowhere.

Just like in Win32, you need a port/context to draw in, and draw the text in that.

Also, I can't see the mouse down event being handled. You just handle the event for the window size being changed. Maybe you need a better template to work from? There is plenty of code around that does what you need.

Okay, i made a little mistake, here's how the code should read:

case kEventMouseDown:
printf("mouse down %d\n", inCommand.commandID);
return true;

but looking to the console, there is no text there that reads: "mouse down #"

Why?