bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -setTarget: and -setAction: of NSImageView


From: Kazunobu Kuriyama
Subject: Re: -setTarget: and -setAction: of NSImageView
Date: Tue, 23 Dec 2003 06:48:54 +0900
User-agent: Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.4) Gecko/20030624 Netscape/7.1



Alexander Malmberg wrote:

Kazunobu Kuriyama wrote:
[snip]

Therefore, contrary to my expectation (as well as everybody's, I hope),
NSImageView doesn't accept both of two methods.

The current behavior is consistent with the documentation, and since an
NSImageView/NSImageCell doesn't actually send any actions to any
targets, it's fairly sensible to have it raise an exception for these
methods.

Consistent?  But NSImageView is a subclass of NSControl, why can't
I expect NSImageView accepts the methods?


How do you define "accept"? The NSImageView does respond to these
messages, and sends them on to NSImageCell, which also responds and
raises an exception, as documented. If you used a different cell (a
custom cell, or eg. an NSActionCell), you'd see different behavior.

By "accept", I mean whatever one can expects from the target/action
paradigm.  The behavior you mention is GNUstep's one due to the
current implementation.  I understand this very clearly.  So
I send the email to bug-gnustep because I think it is a bug.



I think my expectation
is quite natural.  I also read AppKit.pdf, but I can't find
there that NSImageView is allowed to reject the methods.


The documentation makes it clear that NSControl merely sends -setTarget:
and -setAction: on to its cell, and it also makes it clear that
NSImageCell raises an exception when you send those messages to it.
Anyway, I'll ask again:

Then, why is NSViewImage a subclass of NSControl?  I think
there is a gap in your argument.  To be sure, NSControl sends
-setTarget: and -setAction: on its cell.  True, NSImageCell raises
an exception when it gets -setTarget: or -setAction:.  But you
fail to fill the gap between the two statements.

What behavior did you expect?


Ie. when you call [anImageView setTarget: foo];, what do you except the
image view/cell to do? Silently ignore the call, or somehow use the
target? If so, how? When does it send an action?

In a class, NSImageView is used as an outlet.  The class is a bare-bones
version of NSDocument.  By setting
 [anImageView setTarget: self];
 [anImageView setAction:  aMethodOfSelf];
the class is designed to reflect the change of the image contained in
an NSImageView (edit or drag-and-drop) to the viewer's size and
a flag indicating that the image is modified.



[snip]

Don't call -setTarget: and -setAction: on an NSImageView? :)


Hmm...  I found that problem when I was trying an example of S. Anguish,
E.M. Buck and D.A. Yacktman, "Cocoa Programming", SAMS, 2002.  Do you
mean they give a wrong usage of NSImageView?  That's beyond my judgement.


Without seeing the example, I can't say what they're trying to do, or
whether it's correct.

Attached is the sample code taken from the book.
(http://www.cocoaprogramming.net)
You can see the "problematic" usage of NSImageView in MYDocument.m



Also, why did you reply in private? The mailing list is more appropriate
since others might be interested in the discussion, or know something
about issue.

Sorry for that.  I don't know why it happend and didn't do that purposely.
Hope this email goes to the right place.



- Alexander Malmberg

Attachment: ImageViewer2.tar.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]