在滚动时获取列表元素边界或框架 [英] Get list element bounds or frame on scrolling

查看:143
本文介绍了在滚动时获取列表元素边界或框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与获取滚动条位置有关NSScroller的飞行



但现在我想知道如何获取当前位置的列表元素(绿色rect)滚动。



[self bounds] [self frame] [[self enclosingScrollView]



编辑 / c>

内部框架[NSScrollView enclosingScrollView] contentView]] 我们看到 NSBox '。
当我点击 NSBox 这是list元素的三角形, NSBox 的实例存储在 -activeTicketRow ,我想我可以得到 NSBox 坐标 NSScrollView 框架 [[NSScrollView enclosingScrollView] contentView]] bounds更改,但阅读视图编程指南后,我想不是。



我已在 NSScrollView中添加了observer

  [[NSNotificationCenter defaultCenter] 
addObserver:self
选择器:@selector(updateConvMenu :)
名称:NSViewBoundsDidChangeNotification
对象:[[self enclosingScrollView] contentView]
] ;



$ c> -updateConvMenu 我得到坐标 [[self enclosingScrollView] contentView] ,这是很好。



QUESTION



不,我想存储 NSBox 这个三角形被点击)从 [[self enclosingScrollView] contentView] 里面 -activeTicketRow 所以我可以得到它的帧坐标时, -updateConvMenu [[self enclosingScrollView] contentView] bounds更改。



我想现在这个问题更容易阅读。

解决方案

滚动列表时,在列表中所选项目的水平中心不在特定边界之后,其与 [NSScrollView frame] 重叠。


this question is related to Get scroll bar position of an NSScroller on the fly

But now i would like to know how to get current position of list element (green rect) on scrolling.

[self bounds] or [self frame] or [[self enclosingScrollView] ...] won't work for this kind of thing or i'm using it in wrong way.

EDIT

Inside frame of [[NSScrollView enclosingScrollView] contentView]] we see list of NSBox's. When i click on triangle of NSBox which is list element, instance of that NSBox is stored in -activeTicketRow, i've thought that i can then get NSBox coordinates inside NSScrollView frame when [[NSScrollView enclosingScrollView] contentView]] bounds changes, but after reading "View Programming Guide" i guess not.

I've added observer in NSScrollView

[[NSNotificationCenter defaultCenter] 
    addObserver:self
    selector:@selector(updateConvMenu:)
    name:NSViewBoundsDidChangeNotification
    object:[[self enclosingScrollView] contentView]
];

and in -updateConvMenu i get coordinates of [[self enclosingScrollView] contentView], so that's good.

QUESTION

No i would like to store NSBox (which triangle was clicked) from [[self enclosingScrollView] contentView] inside -activeTicketRow so i can then get it's frame coordinates in -updateConvMenu when [[self enclosingScrollView] contentView] bounds changes.

I think now this question is more readable.

解决方案

When scrolling through the list, i'm calculating whether the horizontal center of the selected item in the list does not go after a specific bounds, which overlaps on [NSScrollView frame].

这篇关于在滚动时获取列表元素边界或框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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