• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A Quick Look contribution and a question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Quick Look contribution and a question


  • Subject: Re: A Quick Look contribution and a question
  • From: Seth Willits <email@hidden>
  • Date: Mon, 3 Jan 2011 08:51:18 -0800

On Jan 3, 2011, at 8:42 AM, Brad Stone wrote:

> I don't think the Quick Look documentation is as robust as it can be, I'm still trying to figure out how to do the same thing the right way.


Roughly:



@interface MyView : NSView <QLPreviewPanelDataSource, QLPreviewPanelDelegate> {
    QLPreviewPanel * mQLPreviewPanel;
}



- (IBAction)toggleQuickLook:(id)sender;
{
    if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible]) {
        [[QLPreviewPanel sharedPreviewPanel] orderOut:nil];
    } else {
        [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];
    }
}




// Quick Look panel support
// ------------------------------------

- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel;
{
    return YES;
}


- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel;
{
    // This view is now responsible of the preview panel
    // It is allowed to set the delegate, data source and refresh panel.
    mQLPreviewPanel = [panel retain];
    panel.delegate = self;
    panel.dataSource = self;
}


- (void)endPreviewPanelControl:(QLPreviewPanel *)panel;
{
    // This document loses its responsisibility on the preview panel
    // Until the next call to -beginPreviewPanelControl: it must not
    // change the panel's delegate, data source or refresh it.
    [mQLPreviewPanel release];
    mQLPreviewPanel = nil;
}




// Quick Look panel data source
// ------------------------------------

- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel;
{
    return [self.controller.selectedItems count];
}


- (id <QLPreviewItem>)previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index;
{
    return [self.controller.selectedItems objectAtIndex:index];
}




// Quick Look panel delegate
// ------------------------------------

//- (BOOL)previewPanel:(QLPreviewPanel *)panel handleEvent:(NSEvent *)event
//{
//  // redirect all key down events to the view
//  if ([event type] == NSKeyDown) {
//      [self keyDown:event];
//      return YES;
//  }
//  return NO;
//}


// This delegate method provides the rect on screen from which the panel will zoom.
- (NSRect)previewPanel:(QLPreviewPanel *)panel sourceFrameOnScreenForPreviewItem:(id <QLPreviewItem>)item;
{
    NSRect boundsInView = ...;
    NSRect boundsOnScreen = [self convertRectToBase:boundsInView];

    boundsOnScreen.origin = [[self window] convertBaseToScreen:boundsOnScreen.origin];

    return boundsOnScreen;
}


// This delegate method provides a transition image between the table view and the preview panel
- (id)previewPanel:(QLPreviewPanel *)panel transitionImageForPreviewItem:(id <QLPreviewItem>)item contentRect:(NSRect *)contentRect
{
    return [self.controller imageForItems:[NSArray arrayWithObject:item]];
}




--
Seth Willits



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >A Quick Look contribution and a question (From: Brad Stone <email@hidden>)

  • Prev by Date: A Quick Look contribution and a question
  • Next by Date: Problems with edit text bounding box cell inside a NSOutlineView
  • Previous by thread: A Quick Look contribution and a question
  • Next by thread: Re: A Quick Look contribution and a question
  • Index(es):
    • Date
    • Thread