2012-07-20 26 views
0

我是新來這個技術,我想在Right click父節點子節點顯示不同上下文菜單 ..如何在NSOutlineView中創建右鍵菜單?

+1

http://whathaveyoutried.com&https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSOutlineView_Class/Reference/Reference.html – Dustin 2012-07-20 15:11:02

回答

1

子類NSOutlineView和實施- (NSMenu *)menuForEvent:(NSEvent *)theEvent

-(NSMenu*)menuForEvent:(NSEvent*)evt 
{ 
    NSLog(@"menuForEvent %@ %@",self, [self delegate]); 
    NSPoint pt = [self convertPoint:[evt locationInWindow] fromView:nil]; 
    int row=[self rowAtPoint:pt]; 
    // create menu .. 
    return menu; 
} 

在Mac OS 10.5以上,在筆尖並設置委託創建NSmenu和實施-(void)menuNeedsUpdate:(NSMenu *)menu

相關問題