I would like to be notified whenever a certain NSView
's - (NSRect)visibleRect
changes because I want to do some fancy subview layout based on the visible rect. Frankly, right now I'm stumped; -visibleRect
doesn't emit KVO notifications (which makes sense), and there doesn't seem to be way to find out if the visible rect changed or not without explicitly calling -visibleRect
.
Is this at all possible? (or is it a terrible, terrible idea?)
I think you can either override -[NSView updateTrackingAreas]
or listen for NSViewDidUpdateTrackingAreasNotification
. Those may happen on more occasions than just a change of the visible rect, but they should happen for any change of the visible rect. I think.
That said, it may be a terrible idea. Hard to know. :)
Another option post 10.5 is the -viewWillDraw method which is called just prior to the view (and its subviews) being drawn. You can fetch the view's visible rectangle and perform layout prior to calling [super viewWillDraw].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With