Skip to content

Mac CCResponder refactoring #1191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 11, 2015

Conversation

andykorth
Copy link
Contributor

Refactoring the Mac input code with these goals:

  • Reduce number of similar mouse event types sent to make it more uniform.
  • Clean up [CCDirector bind:] calls- there were too many before due tot he copy-pasted code
  • Reduce the amount of duplicated code
  • Add support for mouseMoved events.

The API for handling mouse events has been reduced from 9 methods to 3. Before, we had mouseUp (left mouse button), rightMouseUp, and otherMouseUp, etc. Now, mouseUp is passed a CCMouseButton. I'd like feedback on that change.

The CCMouseButton enum was moved between headers. I considered removing it in favor of the already existing NSEventType enum. However, I decided against changing the existing code for compatibility and because those events are sort of complicated, they encapsulate both mouse button and state: NSLeftMouseDown, NSOtherMouseUp, etc. Thoughts on that would be appreciated also.

In this pull request, the commits are well organized, so you might want to review it by going through each commit one at a time. The purposes of each change should be quite clear that way.

@@ -133,13 +133,13 @@ - (void) mouseUpOutside:(NSEvent*)event
[self inputUpOutside];
}

- (void) mouseDragged:(NSEvent*)event
- (void) mouseDragged:(NSEvent*)event button:(CCMouseButton) button
{
CGPoint dragPos = [event locationInNode:self];

[self inputDraggedWithPos:dragPos];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an if(button == left) check.

slembcke added a commit that referenced this pull request Feb 11, 2015
@slembcke slembcke merged commit 749d1e4 into cocos2d:develop Feb 11, 2015
@slembcke
Copy link
Contributor

Is there anything better we can do than "other" mouse button? It seems really odd after using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants