Standard C++ Carbon Application Template

Member
Posts: 29
Joined: 2008.10
Post: #1
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?
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #2
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.
Quote this message in a reply
Member
Posts: 29
Joined: 2008.10
Post: #3
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?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Trouble With Template Classes in C++ Nick 4 3,168 Nov 21, 2006 10:25 AM
Last Post: DoG
  Trouble with template classes ermitgilsukaru 2 2,631 Aug 11, 2006 02:00 PM
Last Post: ermitgilsukaru
  Anyone use the C++ standard library? Najdorf 10 3,299 Nov 25, 2005 03:40 PM
Last Post: Najdorf
  Template specialization of a method Fenris 4 3,066 Jul 11, 2005 02:45 PM
Last Post: OneSadCookie