Re: NSImageVIew bindings
Re: NSImageVIew bindings
- Subject: Re: NSImageVIew bindings
- From: Francisco Tolmasky <email@hidden>
- Date: Sat, 31 Jan 2004 02:39:29 -0800
OK, here's my code to make sure that I'm not making some silly mistake.
In an awakeFromNib I do this:
imageView= [[MyImageView alloc] initWithFrame: someFrame];
[imageView bind: @"data" toObject: self withKeyPath: @"model.imageData"
options: nil];
(the model is then bound to an nsarraycontroller)
Then, in IB, I have bound a column with an image cell to that
nsarraycontroller's selection.imageData. So theoretically, when you
select different columns, the image in the imageview reflects the image
in the column, which incidently it does. Similarly, if you change the
image in the image view, the image should change in the column, only
this doesn't always work. In fact it only works when I drag something
onto there. When I paste, the image is not updated in the column.
Here is my pasting code in MyImageView to make sure it is correct:
- (IBAction)paste:(id)sender
{
if([NSImage canInitWithPasteboard: [NSPasteboard
generalPasteboard]])
{
[self setImage: [[NSImage alloc] initWithPasteboard:
[NSPasteboard generalPasteboard]]];
}
}
I have tried placing [self willChangeValueForKey: @"data"] and [self
didChangeValueForKey: @"data"] before and after the setImage:, but this
also surprisingly yielded no result. I truly have no idea what is
going on.
Thanks again,
On Jan 31, 2004, at 12:35 AM, Scott Anguish wrote:
>
>
On Jan 31, 2004, at 3:24 AM, Francisco Tolmasky wrote:
>
>
> I've set an image view's bindings to the data object of one of my
>
> internal objects. When I drag and drop an image to the view the
>
> model is properly updated, but for some reason when I call setImage
>
> on the image view the object is not updated. Does anyone know what
>
> could be wrong?
>
>
>
>
That sounds like a bug, although I wonder if it the same behavior is
>
displayed if you try a similar thing with an NSTextField binding..
>
>
>
Anyways.. you should probably set the image by setting the bound data
>
object directly as a work around. (You might be able to force the
>
update by having the imageview send it's target action, if you can't
>
access the model directly for some reason -- I'm not sure)
>
>
Ah, incidentally.... The data provided to the NSImageView via the
>
data binding can be any any of the image types supported by NSImage..
>
but when you change the image, the data is updated as a TIFF
>
representation.
>
>
>
>
>
>
>
Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.