2011-08-09 35 views
1

我想使用NSTableView而不使用the NSTableViewDataSource Methods,但就像普通視圖一樣。 draggingEntered:draggingExited:被調用,但是當我返回NSDragOperationCopy時,我看不到綠色加鼠標指針,並且performDragOperation:未被調用。NSTableView可以處理普通的拖放方法嗎?

我子類的NSTableView的這些方法:

- (void)awakeFromNib 
{ 
    [self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]]; 
} 

- (NSDragOperation)draggingEntered: (id <NSDraggingInfo>)sender 
{ 
    NSLog(@"draggingEntered"); //Gets called 
    return NSDragOperationCopy; 
} 

- (void)draggingExited: (id <NSDraggingInfo>)sender 
{ 
    NSLog(@"draggingExited"); //Gets called 
} 

- (BOOL)performDragOperation: (id <NSDraggingInfo>)sender 
{ 
    NSLog(@"performDragOperation"); //Doesn't get called 
    return YES; 
} 

回答

0

文檔指出:符合NSDraggingDestination和NSDraggingSource協議,所以是應該用手正常拖動和下降。

您可以嘗試使用nsview中的-registerForDraggedTypes:方法。

+0

我試過了,否則'draggingEntered:'和'draggingExited:'不會被調用。 – Jim893