xyz xyz - 6 months ago 10
Objective-C Question

Get list element bounds or frame on scrolling

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.
enter image description here

[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.

xyz xyz
Answer

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].

Comments