Cocoa WebView 拖放

发布于 2024-10-31 04:04:48 字数 1332 浏览 1 评论 0原文


在我的应用程序中,我有一个 NSOutlineView,其中包含一些文件列表和一个 WebView,
用户允许将任何项目从大纲视图拖动到 WebView,在此基础上,我应该处理数据库事务,

在大纲视图中,我已经实现了以下方法,

- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard{
    [self log:@"write Items”];
    // Some other code to prepare the Write Item, 

}
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)index{

}

- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index{

}

在 WebView 端,我已经实现了以下方法,

- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
    NSPasteboard *pboard;
    NSDragOperation sourceDragMask;

    [self log:@"Inside draggingEntered”];
return NSDragOperationEvery;  
}

- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender{

}
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender{

}

现在当我将一个元素从大纲视图拖动到 WebView 时,我可以看到,大纲视图的 writeItem 被调用,
在Webview中,DragEnter从哪里被调用,我不返回拖动操作NONE,但返回NSDragoperationEvery,

问题是,我没有得到方法,prepareForDragOperation和PerformDragOperation,

任何人都可以帮助我请,
亲切的问候
罗汉

In my Application i have one NSOutlineView having list of somefiles and one WebView,
User allows to drag any item from the Outline view to WebView, and on that , i am suppose to handle the database transaction,

In the Outline view , i have implemented following methods,

- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard{
    [self log:@"write Items”];
    // Some other code to prepare the Write Item, 

}
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)index{

}

- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index{

}

On the WebView side, i have implemented following, methods,

- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
    NSPasteboard *pboard;
    NSDragOperation sourceDragMask;

    [self log:@"Inside draggingEntered”];
return NSDragOperationEvery;  
}

- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender{

}
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender{

}

Now when i drag an element from outline view to WebView, i could see, writeItem of Outline view is getting called,
and in the Webview, DragEnter is getting called from where, i am not returning drag operation NONE, but returning NSDragoperationEvery,

The problem is that, i am not getting method, prepareForDragOperation and PerformDragOperation,

Can anyone help me please,
Kind Regards
Rohan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻安 2024-11-07 04:04:48

大家好
感谢您的浏览,
它通过重写解决了

- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender{
    [self log:@"Inside Dragging updated"];
    return NSDragOperationEvery;
}

虽然在文档中它被作为一个选项提到,但如果它没有实现,它将从dragEnter方法获取返回值,

也许对于我自己的数据类型,它会得到NONE形式的WebView方法并且一旦我工作覆盖它。
亲切的问候
罗汉

Hi guys
Thanks for Looking over it,
It got resolved by overriding

- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender{
    [self log:@"Inside Dragging updated"];
    return NSDragOperationEvery;
}

Though in the document it was mentioned as an option and if its not implemented, it will take the return values from dragEnter Method,

perhaps for My own data type, it would have got NONE form WebView method and working once i overwrite it.
Kind Regard
Rohan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文