Re: Which sender is which
Re: Which sender is which
- Subject: Re: Which sender is which
- From: "John C. Welch" <email@hidden>
- Date: Fri, 08 Apr 2011 12:17:10 -0400
- Thread-topic: Which sender is which
Thanks to a random discussion with a little birdie who will go unnamed to
avoid getting him into trouble, problem is solved, duh, by bindings.
I got the suggestion for stuffing the image into the plist as raw data. This
of course, led me to chapter 20 of Shane's book. So for my text fields, I
just bound the value to Shared User Defaults Controller, enabled
Continuously Updates Value, and bang, done.
For the image, I based it on Shane talking about storing NSColorWell data.
Since NSImage and NSImageView both conform to NSCoding, I just bound the
value of the Image View to Shared User Defaults Controller, with the
NSKeyedUnarchiveFromData Value Transformer, and band, done.
It all works, it does what it's supposed to, and in the end, required zero
extra code.
However, I want to thank Peter, Rainer, and of course, Shane for all the
help they gave me. Even when an idea didn't work, it taught me a bunch of
stuff I didn't know.
Bindings are indeed, awesome.
On 4/8/11 8:29 AM, "John Welch" <email@hidden> wrote:
> Just to make sure I'm not getting so wrapped up in dealing with this in only
> one way...is there a way other than tracking file location and control and
> saving them to application preferences to save/embed a specific image in an
> image well/image view that persists across application restarts until
> manually changed by the user?
>
> On 4/7/11 5:39 PM, "John Welch" <email@hidden> wrote:
>
>> 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.
_______________________________________________
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