Article View: comp.sys.next.programmer
Article #2150Problems with the appIcon "window"
From: Gordie Freedman
Date: Sat, 19 Dec 1992 10:28
Date: Sat, 19 Dec 1992 10:28
64 lines
3185 bytes
3185 bytes
I have an application that sets up for dragging events in the app icon. I'm
having some problems dragging file icons onto the app icon.
I noticed that I couldn't set the delegate for the appIcon using the
setDelegate method. Anybody know why? Here's the code ...
// In my controller object, which is the delegate of the Application
// as set in Interface Builder ...
- appDidInit:sender
{
id iconWindow = [NXApp appIcon];
[iconWindow setDelegate:self];
[iconWindow registerForDraggedTypes:pboardType count:1];
return self;
}
This didn't work, looking at it in gdb, I could see that the delegate member of
the iconWindow object was still 0x0 after the setDelegate. Needless to say, my
object did not get the messages a delegate would expect.
I did get this to work with one of the "normal" windows in my app, and the
following kludge "almost" works for the iconWindow:
- appDidInit:sender
{
id iconWindow = [NXApp appIcon];
struct windowDef {
@defs(Window)
} *public;
public = (struct windowDef*) iconWindow;
public->delegate = self;
[iconWindow registerForDraggedTypes:pboardType count:1];
return self;
}
This is nasty and breaks the rules of encapsulation.
For more confusion, the program does not work correctly if launched via "open
xxx.app", or by double clicking the app icon. When I do this (the recommended
way to start an App, and the way it is autolaunched too, btw) the
draggingEntered method is not invoked. If I double click on the executable in
the app directory, it works, accepting the drag and invoking the correct
delegate method. Using good old printf, it looks like all of the methods I
invoke work, however the draggingEntered method never gets invoked for the
delegate when I launch it as an app. This is pretty strange.
I know there are two other ways to do this, one is to use some 2.0 type code
(iconEntered and iconReleasedAt) which is no longer supported (works great
though, thanks to the person who sent me the example code - sorry I lost your
email address). I'm just afraid to use code that is no longer recommended (as
per the 3.0 Release Notes: Application Kit). The other method forces you to
hold down the command key when dragging, and uses the appAcceptsAnotherFile and
app:sender openFile:... methods. This is nice (thanks Gary), but I would like
to get it to work where you don't have to hold down command during the drag.
Mainly I'm curious too - what's with the App Icon "Window"!?
Thanks for any help/info in advance ...
--
Gordie Freedman gordie@yamanote.dolphin.com -> NextMail encouraged
(Disclaimer: Opinions expressed are my own and represent no one else.)
Technical Details
Message-ID:
<1992Dec19.102849.24327@netcom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!uwm.edu!spool.mu.edu!umn.edu!csus.edu!netcom.com!netcomsv!yamanote!gordieShow Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!uwm.edu!spool.mu.edu!umn.edu!csus.edu!netcom.com!netcomsv!yamanote!gordie From: gordie@yamanote.dolphin.com (Gordie Freedman) Subject: Problems with the appIcon "window" Message-ID: <1992Dec19.102849.24327@netcom.com> Sender: gordie@netcom.com Reply-To: gordie@yamanote.dolphin.com Organization: Dolphin Software Date: Sat, 19 Dec 1992 10:28:49 GMT Lines: 65