验证对 NSCollectionView 的拖动不会在视觉上反映出来
我有一个 NSCollectionView,我想接受从应用程序中其他地方拖动的项目。
我在collectionview的委托中实现collectionView:validateDrop:proposedIndex:dropOperation:
和collectionView:acceptDrop:index:dropOperation:
并注册适当的拖动类型。当我拖动适当的类型时,这两种方法都可以正常调用,但是在集合视图上没有看到指示有效拖动的蓝色焦点环。
已在聚焦环的默认和外部设置上尝试了集合视图及其包含的滚动视图。两者都只是标准的非派生 Cocoa 类。想知道是否还有其他我应该尝试的事情。当然没有必要为此子类化 NSCollectionView 吗?
谢谢
克里斯
I have an NSCollectionView that I want to accept items dragged from elsewhere in my application.
I implement collectionView:validateDrop:proposedIndex:dropOperation:
and collectionView:acceptDrop:index:dropOperation:
in the collectionview's delegate and register for the appropriate dragged types. Both methods get called fine when I drag the appropriate types, but I don't get a blue focus ring over the collectionview indicating a valid drag.
Have tried both the collection view and its containing scroll view on Default and External settings for the focus ring. Both are just the standard non-derived Cocoa classes. Wondered if there was anything else I should try. Surely it isn't necessary to subclass NSCollectionView for this?
Thanks
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
聚焦环通常不是提供有关拖动目的地的反馈的正确方法。每个视图的做法都略有不同。 NSTextView 显示插入栏。 NSTableView 在
Before
放置操作的行之间显示一条蓝线,并在On
放置操作的行周围显示边框。 (参见 NSTableViewDropOperation)NSCollectionView 在现有子视图之间显示一个“间隙”,以显示在
Before
放置操作中项目将被放置的位置,并且它将设置selected<将 NSCollectionViewItem 上的 /code> 属性设置为
YES
以进行On
放置操作。 (注意:默认情况下,NSCollectionViewItem 不会执行任何操作来明显地表示selected
属性。您必须自己实现。)由于 NSCollectionView 的反馈仅使用现有的子视图,因此似乎根本没有任何反馈对于空的 NSCollectionView。您需要子类化才能自己提供此行为。您还可以提交一个错误来请求 NSCollectionView 自己执行此操作。
Focus rings are not typically the correct way to provide feedback about drag destinations. Every view does it slightly differently. NSTextView shows the insertion bar. NSTableView shows a blue line in between rows for
Before
drop operations, and shows a bezel around the row forOn
drop operations. (SeeNSTableViewDropOperation
)NSCollectionView shows a "gap" between existing subviews to show where the items will be dropped for
Before
drop operations, and it will set theselected
property on NSCollectionViewItem toYES
forOn
drop operations. (Note: NSCollectionViewItem doesn't do anything by default to visibly represent theselected
property. You must implement that yourself.)Since NSCollectionView's feedback uses existing subviews only, it appears there isn't any feedback at all for empty NSCollectionView's. You would need to subclass to provide this behavior yourself. You could also file a bug to request that NSCollectionView do this itself.