Re: Which sender is which
Re: Which sender is which
- Subject: Re: Which sender is which
- From: "John C. Welch" <email@hidden>
- Date: Thu, 07 Apr 2011 17:39:47 -0400
- Thread-topic: Which sender is which
Okay, so I think I'm seeing the problem.
I had, per chapter 10 of shane's book, created a subclass of NSImageView to
handle certain things, like getting the URL of the file. However, if I did
that, I couldn't set up the drag info as you did with your sample code to
get the sender info. But, I could get the fURL info from it.
So, on a lark, I stopped pointing the image wells at the subclass, and put
the code in the subclass in the main script. Okay, so now I can connect
everything up, and I get the the right info when I log things.
But the URL code blows up. Here's the code:
on performDragOperation_(sender)
tell current application's NSImage to set picTypes to imageTypes()
log picTypes
set thePasteboard to sender's draggingPasteboard()
set theClasses to {current application's |NSURL|}
set theOptions to
{NSPasteboardURLReadingContentsConformToTypesKey:picTypes}
tell thePasteboard to set imageURLs to
readObjectsForClasses_options_(theClasses, theOptions)
set theURL to item 1 of (imageURLs as list)
set theTag to sender's |tag|
if sender is pathDataTop then
log "top"
else if sender is pathDataRight then
log "right"
else if sender is pathDataLeft then
log "left"
else
log "none of the above"
end if
log theURL
return true
end performDragOperation_
As soon as it gets to the set thePasteboard to sender's draggingPasteboard()
line, I get:
2011-04-07 17:32:56.242 Derby Score[3532:903] *** -[Derby_ScoreAppDelegate
performDragOperation:]: -[NSImageView draggingPasteboard]: unrecognized
selector sent to instance 0x2008b02e0 (error -10000)
Which really doesn't make sense, because in the examples I found on
macscripter and elsewhere, that line should work. And yet, it generates that
error. The first two lines work, and if I comment out all the fURL getting'
code, I can see which image well I used.
This is getting confuuuuusing.
--
"Any Time, Any Place"
USAF 16th SOW
On 4/7/11 4:23 PM, "Bukowinski, Peter" <email@hidden> wrote:
> I just threw together a dummy app and I'm getting good results.
>
> Here's my code:
>
> script ImageWellTestAppDelegate
> property parent : class "NSObject"
> property theFirstWell : missing value
> property theSecondWell : missing value
>
> on objectInWell_(sender)
> if sender is theFirstWell then
> log "first"
> else if sender is theSecondWell then
> log "second"
> else
> log "I dunno"
> end if
> end objectInWell_
>
> on applicationWillFinishLaunching_(aNotification)
> -- nothing to see here
> end applicationWillFinishLaunching_
>
> on applicationShouldTerminate_(sender)
> return current application's NSTerminateNow
> end applicationShouldTerminate_
> end script
>
> For the interface, I just put a couple image wells into a window. I then
> dragged a connection from the app delegate to each well, selecting the
> first and second properties, respectively. Then I dragged a connection
> back from each to the app delegate, selecting the objectInWell: handler.
>
> My log returns "first" and "second" reliably. I'm using Xcode 4.0.1.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden