I can't seem to find a way to implement something I've been working on... Is there a way to tell if a Menu already contains a MenuItem that is set to selected? For example, I've got a Menu with 12 MenuItemImages. I want to be able to click on one image, and it will be selected (switching to the "selected" image appropriately).
I've got that working fine, but now every button I tap gets selected and remains selected. I'd like to be able to check to see if another item is selected, if so, deselect that one and select the most recent tap. Here's an example of my code:
- (void) init {
// normal layer setup stuff
MenuItemImage *image1 = [MenuItemImage itemFromNormalImage:@"image1.png"
selectedImage:@"image1_sel.png"
target:self
selector:@selector(setSelectedImage:)];
MenuItemImage *image2 = [MenuItemImage itemFromNormalImage:@"image2.png"
selectedImage:@"image1_sel.png"
target:self
selector:@selector(setSelectedImage:)];
// and so on, for a few more items
Menu *menu = [Menu menuWithItems: image1, image2, [and on and on], nil];
// menu position and alignment, then add child on top of all other layers
}
- (void) setSelectedImage: (id)sender {
[sender selected];
}
Thanks in advance for any help you can offer!