自定义NSTableView拖动会话,但拖动框坐标不是tableview吗? [英] Customize NSTableView dragging session but dragging frame coordinate is not the tableview?

查看:99
本文介绍了自定义NSTableView拖动会话,但拖动框坐标不是tableview吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-(void)tableView:(NSTableView *)tableView
 draggingSession: (NSDraggingSession *)session
willBeginAtPoint:(NSPoint)screenPoint
   forRowIndexes:(NSIndexSet *)rowIndexes {
  [session enumerateDraggingItemsWithOptions:NSDraggingItemEnumerationConcurrent
                                 forView:tableView
                                 classes:[NSArray arrayWithObject:[NSPasteboardItem class]]
                           searchOptions:nil
                              usingBlock:^(NSDraggingItem *draggingItem, NSInteger index, BOOL *stop) {
                                NSImage *image = [NSImage imageNamed:@"about_bg"];

                                [draggingItem setDraggingFrame:NSMakeRect(0, 0, 100, 100)
                                                      contents:image];
                              }];

}

就像图片所示,拖动图片的位置不是鼠标点的位置. 有人知道为什么吗?感谢您的帮助~~ ^ _ ^

just like the picture shows, the location of dragging picture is not the mouse point location. Dose anybody know why? Thanks for help~~^_^

推荐答案

我认为此问题的原因是我的英语不佳,我对苹果doc并不完全理解.并感谢@Willeke的帮助. 我应该做的就是不要更改拖动框.因此,只需将[draggingItem draggingFrame]设置为draggingFrame.( ̄▽ ̄) 我认为这是一个非常愚蠢的问题,哈哈~~

I think the reason of this problem is my poor english, I didn't understand the apple doc completely. and thanks @Willeke for the help. what I should do is not to change the dragging frame. So just set [draggingItem draggingFrame] to draggingFrame.( ̄▽ ̄) I think this is a very stupid question, haha~~

这篇关于自定义NSTableView拖动会话,但拖动框坐标不是tableview吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆