[Top][All Lists]

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

[PATCH (revised)] -setTarget: and -setAction of NSImageView

From: Kazunobu Kuriyama
Subject: [PATCH (revised)] -setTarget: and -setAction of NSImageView
Date: Thu, 25 Dec 2003 18:11:15 +0900
User-agent: Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.4) Gecko/20030624 Netscape/7.1


Attached are revised patches to make NSImageView receive -setTarget:
-setAction methods and invoke the action when an image on another view
is dragged and dropped onto an NSImageView in question.

According to two suggestions I got so far, each of whic by Alexander
Malmberg and Fred Kiefer respectively, I offer two solutions. This is
because I'm not sure which is better and think decision should be made
on the basis of broader point of view, which I can't say I have. I
appreciate it very much if someone could do it.

I hope, at least, these patches help further discussion on the
issue by virtue of saving someone's labor.

Solution01: Make NSImageCell is a subclass of NSActionCell

Changed Files: NSImageCell.h, NSImageView.m, and ChangeLog

(pros) Only few lines of code to modify the behavior of NSImageView.
(possibly) Doesn't require recompilation of applications.
(cons) Doesn't conform to doc.
Extra methods inherited from NSActionCell proper.

According to the suggestion by Alexander Malmberg, -performSelector
is replaced with -sendAction:to:. However, no changes are made
in -initWithCoder: or -encodeWithCoder:, because the modification
doesn't add new ivars. Also, because -initWithCoder: and -encodeWithCoder:
of all relevant classes look fine to me, I'm wondering if they really need
to be modified.

Solution02: Keep NSImageCell a direct subclass of NSCell and
and add new ivars to it

Changed Files: NSImageCell.h, NSImageCell.m, NSImageView.m, and ChangeLog

(pros) Conforms to doc.
(cons) (possibly) Requires recompilation of applications.
Though NSImageCell is a direct subclass of NSCell, it receives
-setTarget: and -setAction: without raising an exception.
A little bit confusing, raising another question, "What is
NSActionCell for?"

This solution owes to Fred Kiefer's suggestion. Because some new ivars are
added to NSImageCell:, -initWithCoder and -encodeWithCoder: are modified so
that they can deals with the new ivars properly. The class's version is
changed to 2 from 1 to guarantee backward compatibility to some extent. New
methods relevant to target/action are also added: most of them are
of those found in NSActionCell.

The target/action ivars are held in NSImageCell. They are explicitly invoked
with -performDragOperation: of NSImageView. This method sets a given new
image only if the view is editable.

Now an action is in NSImageCell, it might be accidentally/unexpectedly
called, dependening on a given situation. If so, this requires
another fix on the patches or somewhere in -gui. Some tests on this
is highly likely to be needed.

- Kazunobu Kuriyama

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

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

reply via email to

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