home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / next / programm / 7835 < prev    next >
Encoding:
Text File  |  1992-12-21  |  3.0 KB  |  77 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!cs.utexas.edu!uwm.edu!spool.mu.edu!umn.edu!csus.edu!netcom.com!netcomsv!yamanote!gordie
  3. From: gordie@yamanote.dolphin.com (Gordie Freedman)
  4. Subject: Problems with the appIcon "window"
  5. Message-ID: <1992Dec19.102849.24327@netcom.com>
  6. Sender: gordie@netcom.com
  7. Reply-To: gordie@yamanote.dolphin.com
  8. Organization: Dolphin Software
  9. Date: Sat, 19 Dec 1992 10:28:49 GMT
  10. Lines: 65
  11.  
  12. I have an application that sets up for dragging events in the app icon. I'm  
  13. having some problems dragging file icons onto the app icon. 
  14.  
  15. I noticed that I couldn't set the delegate for the appIcon using the  
  16. setDelegate method. Anybody know why? Here's the code ...
  17.  
  18. // In my controller object, which is the delegate of the Application
  19. // as set in Interface Builder ...
  20. - appDidInit:sender
  21. {
  22.     id iconWindow = [NXApp appIcon];
  23.     
  24.     [iconWindow setDelegate:self];
  25.     [iconWindow registerForDraggedTypes:pboardType count:1];
  26.     return self;
  27. }
  28.  
  29. This didn't work, looking at it in gdb, I could see that the delegate member of  
  30. the iconWindow object was still 0x0 after the setDelegate. Needless to say, my  
  31. object did not get the messages a delegate would expect.
  32.  
  33. I did get this to work with one of the "normal" windows in my app, and the  
  34. following kludge "almost" works for the iconWindow:
  35.  
  36. - appDidInit:sender
  37. {
  38.     id iconWindow = [NXApp appIcon];
  39.     
  40.     struct windowDef {
  41.         @defs(Window)
  42.     } *public;
  43.  
  44.     public = (struct windowDef*) iconWindow;
  45.     public->delegate = self;
  46.     [iconWindow registerForDraggedTypes:pboardType count:1];
  47.     return self;
  48. }
  49.  
  50. This is nasty and breaks the rules of encapsulation. 
  51.  
  52. For more confusion, the program does not work correctly if launched via "open  
  53. xxx.app", or by double clicking the app icon. When I do this (the recommended  
  54. way to start an App, and the way it is autolaunched too, btw) the  
  55. draggingEntered method is not invoked. If I double click on the executable in  
  56. the app directory, it works, accepting the drag and invoking the correct  
  57. delegate method. Using good old printf, it looks like all of the methods I  
  58. invoke work, however the draggingEntered method never gets invoked for the  
  59. delegate when I launch it as an app. This is pretty strange. 
  60.  
  61. I know there are two other ways to do this, one is to use some 2.0 type code  
  62. (iconEntered and iconReleasedAt) which is no longer supported (works great  
  63. though, thanks to the person who sent me the example code - sorry I lost your  
  64. email address). I'm just afraid to use code that is no longer recommended (as  
  65. per the 3.0 Release Notes: Application Kit). The other method forces you to  
  66. hold down the command key when dragging, and uses the appAcceptsAnotherFile and  
  67. app:sender openFile:... methods. This is nice (thanks Gary), but I would like  
  68. to get it to work where you don't have to hold down command during the drag.
  69.  
  70. Mainly I'm curious too - what's with the App Icon "Window"!?
  71.  
  72. Thanks for any help/info in advance ...
  73. -- 
  74. Gordie Freedman gordie@yamanote.dolphin.com   ->   NextMail encouraged
  75. (Disclaimer: Opinions expressed are my own and represent no one else.)
  76.  
  77.