discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBrowser question


From: Sašo Kiselkov
Subject: Re: NSBrowser question
Date: Sat, 26 Nov 2005 19:43:29 +0100
User-agent: Internet Messaging Program (IMP) 3.2.5

Quoting Andreas Höschler <ahoesch@smartsoft.de>:

> Hello all,
>
> I have done the following
>
>     [browser setMatrixClass:[FinderBrowserMatrix class]];
>
> in order to implement dragging in a browser so I get a call to
>
>       - (void)mouseDown:(NSEvent *)event
>
> on an instance of FinderBrowserMatrix. Any idea how I  get back to the
> browser in this method? Via superview I got to the ScrollView and
> expected the documentView of the NSScrollView to be the browser (like I
> set it up), but the documentview is an instance of FinderBrowserMatrix!?

No, it behaves correctly. Your problem is that NSBrowser creates a scroll view
for each of it's columns and puts an instance of your view's class inside such
a scroll view. Therefore, the right (though a bit dirty) way is the following:

@implementation NSView (FindingMyBrowserAdditions)
// finds the nearest enclosing browser view and returns it
- (NSBrowser *) enclosingBrowser
{
  NSView * view;

  for (view = [self superview]; view != nil; view = [view superview])
    {
      if ([view isKindOfClass: [NSBrowser class]])
        {
          break;
        }
    }

  return (NSBrowser *) view;
}
@end

>
> Thanks a lot!
>
> Regards,
>
>    Andreas
>

You're welcome ;-)

--
Saso






reply via email to

[Prev in Thread] Current Thread [Next in Thread]