summary refs log blame commit diff stats
path: root/Classes/NMPanelMenu.m
blob: ee242795c0bdf078e6226c08ce3217960da3f2cd (plain) (tree)



































                                                                             
/*
 *  NMPanelMenu.m
 *  shapes
 *
 *  Created by Nate Murray on 7/29/10.
 *  Copyright 2010 YetiApps. All rights reserved.
 *
 */

#import "NMPanelMenu.h"

@implementation NMPanelMenu

-(CCMenuItem *) itemForTouch: (UITouch *) touch
{
    CGPoint touchLocation = [touch locationInView: [[touch view] superview]];
    touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];

    CCMenuItem* item;
    CCARRAY_FOREACH(children_, item){
        // ignore invisible and disabled items: issue #779, #866
        if ( [item visible] && [item isEnabled] ) {

            CGPoint local = [item convertToNodeSpace:touchLocation];

            CGRect r = [item rect];
            r.origin = CGPointZero;

            if( CGRectContainsPoint( r, local ) ) {
                return item;
            }
        }
    }
    return nil;
}

@end