Monday, December 11, 2017

#1 2009-10-09 04:08:51 am

robdut
Member
Registered: 2009-09-02
Posts: 301

tableView Drag and drop

I will start a new topic here but my sample project is still the two-tables project using array controllers and bindings.

I have spent several days trying to understand and implement drag and drop but it seems daunting. This may be one  for oBJ-C classes to handle.

I have read that you can use dataSource along side the bindings so I am doing that since the drag and drop methods are for the dataSource.

So far I have:

1. connected the tableViews outlet to my app delegate script and selected "datasource" - I know this works because I had tried (unsuccessfully) to use dataSource methods for tableView:objectValueForTableColumn:row: and the methods were getting called.

2. added:

Applescript:

on awakeFromNib()
   set aTableViewsDragTypes to NSArray's arrayWithObject_("NSFilenamesPboardType", missing value)
   log aTableViewsDragTypes
   aTableView's registerForDraggedTypes_(aTableViewsDragTypes)

the log shows:

Applescript:

(
NSFilenamesPboardType
)

I assume that means it sees the "register" request?

Now the tricky part. You need three methods for the table to accept a drag and drop:

Applescript:

on tableView_writeRowsWithIndexes_toPasteboard_(aTableView, missing value, missing value)
       log "dragOp1"
end tableView_writeRowsWithIndexes_toPasteboard_
   
on tableView_validateDrop_proposedRow_proposedDropOperation_(aTableView, missing value, 1, missing value)
       log "dragOp2"
       return yes
end tableView_validateDrop_proposedRow_proposedDropOperation_
   
on tableView_acceptDrop_row_dropOperation_(aTableView, true, missing value)
       log "dragOp3"
       return yes
end tableView_acceptDrop_row_dropOperation_

As you can see I haven't added and code to these but hope it would at least log that they are called. maybe not.

This used to be so easy from ASS! But that is the challenge. I may attempt to create the class files for this and see if that works... hmmm

here is a pretty clear explanation:
http://www.nongnu.org/gstutorial/en/ch13s04.html

and the docs:
http://developer.apple.com/mac/library/ … d/20000726

Any direction here much appreciated, Rob

Offline

 

#2 2009-10-09 06:25:55 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5197

Re: tableView Drag and drop

I haven't really looked at this stuff, but I wonder whether you need to deal with table columns. IAC, it might be simpler to get it working with something more basic than a table first.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2009-10-09 07:35:20 am

robdut
Member
Registered: 2009-09-02
Posts: 301

Re: tableView Drag and drop

Well, I tried getting a text field to accept drop. I have several and the first one, as initial first responder, receives focus when you hover the mouse (the green + sign) but the others need special attention and that requires 6 methods!  So I decided to try the table since it requires only three. I don't see anything about a table column in the docs as being different from, let's say, a text field, but I'll do some more research.

This one seems huge.

Rob

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)