zuerst meinen Code:@selector mit mehreren Argumenten
- (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
{
if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
NSMenu * m = [[NSMenu alloc] init];
if (item != nil) {
NSLog(@"%@",[item title]);
[m addItemWithTitle:[item title] action:@selector(press:) keyEquivalent:@""]; // problem. i want to give "item" as an argument.....
for (NSMenuItem* i in [m itemArray]) {
[i setTarget:self];
}
} else {
[m addItemWithTitle:@"clicked outside" action:nil keyEquivalent:@""];
}
return [m autorelease];
}
return nil;
}
-(void) press:(id)sender{
NSLog(@"PRESS");
}
möchte ich mit einem Wähler item
als Argument für meine press:
Methode geben.
Vielen Dank :)
PS: Ich bin nicht iPhone für den Mac zu tun.
+1 whoops, ich habe übersehen, dass 'item' anders ist als' NSMenuItem'. –
vielen Dank, es hat +1 funktioniert – cocos2dbeginner