• 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: dragging NSTableColumn to another table
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dragging NSTableColumn to another table


  • Subject: Re: dragging NSTableColumn to another table
  • From: Chuck Soper <email@hidden>
  • Date: Tue, 19 Feb 2013 17:10:54 -0800
  • Thread-topic: dragging NSTableColumn to another table

On 2/18/13 11:06 PM, "Graham Cox" <email@hidden> wrote:

>On 19/02/2013, at 11:09 AM, Chuck Soper <email@hidden> wrote:
>
>> Does anyone know the steps to allow custom dragging of a table column to
>> another table? Is this possible? If I was dealing with an NSView
>>subclass,
>> I think this would be straightforward. I want to show the entire column
>> (header + row) when dragging. I believe that the dragging implementation
>> could go in my NSTableHeaderCell subclass, but I'm not sure how to get
>> started.
>
>
>It's definitely possible, but you'll have to do a bit of subclassing. I
>suspect you're going to need to subclass the overall NSTableView so that
>you can receive a private drag type and do the necessary graphics work as
>part of NSDraggingDestination.
>
>There are two parts to a drag - the drag source and the drag destination.
>The source can be your custom table header cell, but the destination is
>probably going to have to be a subclass of the table view itself. The two
>parts can be programmed fairly independently, once you've settled on how
>they are going to communicate in terms of the column data you pass from
>to the other.
>
>Having subclassed your table header cell, kicking off the drag shouldn't
>be too hard - just handle the mouseDown or mouseDragged and capture an
>image of the column as the drag image. NSView's method for capturing part
>of a view to a bitmap rep is invaluable here. Declare a private drag type
>and use whatever data makes sense to pass the column content through the
>drag pasteboard mechanism - you might not need to actually transfer any
>data, you could just store enough info in shared variables (e.g. just
>make a note of the source column somewhere) that your custom table class
>can access - as it's all private there's no need to consider dragging to
>other apps or supporting standard data formats.
>
>The hardest part as I see it is in receiving the drag. Your custom table
>class will register for the private drag type, and implement
>NSDraggingDestination methods to do whatever is needed to provide
>feedback and validation of the drag. You will need for example to
>highlight the place where the column can be dropped, and maybe animate
>moving other columns apart to "make room". You'll want to pass anything
>else up to super's implementation to continue supporting all the standard
>dragging that the table can handle.
>
>On a drop, you just need to remove the column from the source, use the
>private data to recreate it at the destination and insert it into the
>table view.
>
>--Graham


Thanks for your very thorough response. It sounds possible, but quite
labor intensive. So much so, that I think that I should not be using
NSTableView. I was using NSTableView, with one row, as way to horizontally
scroll custom views. To auto adjust the height of the single row I added
an observer for NSViewFrameDidChangeNotification on the NSTableView
object. Then called setRowHeight: to
scrollView.documentVisibleRect.size.height as the table was resized.

This was pretty fast to implement and worked fine. I think that this could
have been a good way to make use of a table view except for needing to
customize the headerCell and implement custom column dragging. I think
that I'll just use an NSScrollView and avoid customizing NSTableView.

Chuck





_______________________________________________

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

  • Follow-Ups:
    • Re: dragging NSTableColumn to another table
      • From: Graham Cox <email@hidden>
References: 
 >Re: dragging NSTableColumn to another table (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: CALayer's backgrounds filters having effect only on immediate parent?
  • Next by Date: Re: dragging NSTableColumn to another table
  • Previous by thread: Re: dragging NSTableColumn to another table
  • Next by thread: Re: dragging NSTableColumn to another table
  • Index(es):
    • Date
    • Thread