views:

31

answers:

1

I have a button that sits on top of an NSScrollView, not within. When the scrollview scrolls, the button get's clipped with part of the button going along with the scrolling and the other part staying positioned.

To better describe the issue here's a video of the issue:

http://dl.dropbox.com/u/170068/ScrollTest.mov

The planned goal was to have a button sit in the top right corner of a text view but stay there when the text view scrolls. So if anyone has any thoughts on how to achieve this it would be greatly appreciated.

A: 

You should subclass NSScrollView and override "tile" method to position sub-controls of the scroll view.

- (void)tile
{
    [super tile];
    if (subControl)
    {
        NSRect subControlFrame = [subControl frame];

        // adjust control position here in the scrollview coordinate space

        // move controls
        [subControl setFrame:subControlFrame];
    }
}

I have used this way to implement a custom ScrollView with zoom control and background color selector embedded.

Gobra
I started trying this until I realized this would require that the button would be a subview of the scoll view, which it's not. There are points in the app when the button will be over the scroll view and points when it won't. Am I missing something? Is there another way to go about this? Thanks for the help.
skabob11
If you need the button to always overlap the scrollview partially than I can suggest you to make a small window, attach it as sub-window to the main and place it over the NSScrollView, put a button onto this window. This should work.
Gobra