Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass scroll events to parent NSScrollView

I need fixed-size NSTextViews inside a larger scrolling window. IB requires that the textviews be inside their own NSScrollViews, even though their min/max sizes are fixed so that they won’t actually scroll. When trackpad gestures are made within the textview frames (regardless of whether they have focus), they are captured by the textviews’ scrollviews, so nothing happens.

How do I tell the textviews’ scrollviews to pass scroll events up to the window’s main scrollview? (Or perhaps I should be asking how I tell the window’s main scrollview to handle these events itself and not pass them on to its child scrollviews.)

The IB structure is like this:

  • window
    • window’s content view
      • big scrollview for window (desired target for scroll events)
        • box
          • swappable content view in separate xib
            • scrollview for textview
              • textview
And, yes, the window does scroll correctly when the textviews do not have focus.
like image 296
Wienke Avatar asked Jun 09 '11 17:06

Wienke


1 Answers

You needn't create a outlet "svActive" to track your super scrollview. Just write this sentence in scrollWheel event:

[[self nextResponder] scrollWheel:event];

this will pass the event to next responder in the responder chain.

like image 145
phaibin Avatar answered Oct 12 '22 15:10

phaibin