Can't get NSScrollView to work

478 views Asked by At

Ok, I've about had it with NSScrollView.

Why is the Y-coordinate flipped, and how can I change it. Also, i must have added hundred of subviews into the Custom View that usually comes with NSScrollView, yet the scrollbars won't activate :(

        var Widget = new TvShowWidgetController ();
        var offset = ContentView.Subviews.Count ();
        Widget.View.SetFrameOrigin (new PointF (0, 150 * offset));
        Widget.View.SetFrameSize (new SizeF (350, 150));
        ContentView.AddSubview (Widget.View);
1

There are 1 answers

0
Laurent Etiemble On BEST ANSWER

The Y-coordinate seems to be flipped because Mac OS is using a coordinate system where the origin (0,0) is the left-bottom corner of the screen. This is different from Windows or Linux where the origin (0,0) is the left-top corner of the screen.

The only way to have a flipped coordinate system in a view, is to subclass NSView and to override the IsFipped method.

The scrollbars will activate only if the size of the contained view changes. Adding subviews to the content view is not enough, as there is no automatic resizing of the content view.