Clay
Clay

Reputation: 2999

cocos2d OS X: How to detect a right-click of the mouse?

In cocos2d for OS X, I'm using ccMouseDown to detect left-clicks of the mouse and ccOtherMouseDown appears to detect clicks of the mouse wheel. I currently am unable to detect right-clicks of the mouse. I also haven't found any information about this in the API.

In cocos2d for OS X, how do I detect right-clicks of the mouse?

Upvotes: 1

Views: 1289

Answers (1)

Clay
Clay

Reputation: 2999

Not sure why this didn't occur to me to begin with, but the proper method is ccRightMouseDown. To respond with the mouse, you have to add self.isMouseEnabled = YES; in your init method.

In total, we have:

// Left click
- (BOOL) ccMouseDown:(NSEvent *)event
{   
    CCLOG(@"Left Mouse Button Clicked");
    return YES;
}

// Right click
- (BOOL) ccRightMouseDown:(NSEvent *)event
{
    CCLOG(@"Right Mouse Button Clicked");   
    return YES;
}

// Mouse wheel click
- (BOOL) ccOtherMouseDown:(NSEvent *)event
{
    CCLOG(@"Mouse Wheel Button Clicked");
    return YES;
}

Upvotes: 1

Related Questions