home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / next / programm / 5673 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  2.9 KB

  1. Path: sparky!uunet!sun-barr!ames!bionet!raven.alaska.edu!acad3.alaska.edu!sxmlk
  2. From: sxmlk@acad3.alaska.edu (KIENENBERGER MIKE L)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Drag and Drop in < NS3.0
  5. Summary: Drag and Drop in < NS3.0
  6. Message-ID: <18AUG199203332039@acad3.alaska.edu>
  7. Date: 18 Aug 92 11:33:00 GMT
  8. References: <1992Aug17.104453.11070@monu6.cc.monash.edu.au>
  9. Sender: news@raven.alaska.edu (USENET News System)
  10. Organization: University of Alaska - Fairbanks
  11. Lines: 63
  12. News-Software: VAX/VMS VNEWS 1.41.UAC
  13. Nntp-Posting-Host: acad3.alaska.edu
  14.  
  15. In article <1992Aug17.104453.11070@monu6.cc.monash.edu.au>, ede978e@monu6.cc.monash.edu.au (Robert D. Nicholson) writes...
  16. >I have to implement Drag and Drop behaviour in NS2.1, but I would also like
  17. >to know wether NS3.0 can do it properly. (Look forward to reading the
  18. >article on it simson)
  19. >OK, I would like to know wether drag and drop can be implemented such that
  20. >the application can determine specifically which window is under the cursor.
  21. >ie. if there are overlapping windows, I must be able to tell which is at the
  22. >top. ie. above all the rest
  23. >Anybody done this?
  24.  
  25. Yes! (Finally.)
  26. The key is the little-known postscript operator "findwindow."
  27.  
  28.     <x> <y> <place> <otherwindow> findwindow <x'> <y'> <window> <bool>
  29.  
  30. (If you're planning on writing your own routine, note that <otherwindow>
  31.  is a local window, while <window> is a global window! If it seems inconsistant
  32.  to you, you are not alone!)
  33.  
  34. Here's how I implemented it.  "currentPoint" is in screen coords.  "dragWindow"
  35. is the id of the window holding the image being dragged. (I want a window UNDER
  36. what is being dragged.)  "acceptViewList" is a list of accepting views.
  37. The id of the first accepting view under the point is returned.  If no
  38. accepting view is found, nil is returned.
  39.  
  40. Many thanks to John Immordino at NeXTedge Developer Support who pointed out
  41. findwindow to me when I really needed it!
  42.  
  43. 26-line routine follows. 
  44. =============================================================================
  45. -Mike Kienenberger                       SXMLK@ALASKA           (BITNet)
  46.  University of Alaska Computer Network   SXMLK@acad3.alaska.edu (Internet)
  47.  University of Alaska-Fairbanks
  48. =============================================================================
  49.  
  50. - checkForAcceptView:(NXPoint *)currentPoint under:dragWindow
  51. {
  52.     int count = 0;
  53.     id currentView;
  54.     unsigned int localWindowNumber;
  55.     float dummy;
  56.     int pwinFound;
  57.     int pdidFind;
  58.  
  59.     PSfindwindow(currentPoint->x, currentPoint->y,
  60.          NX_BELOW, [dragWindow windowNum],
  61.          &dummy, &dummy, &pwinFound, &pdidFind);
  62.     if (0 == pdidFind)  return nil;
  63.  
  64.     NXConvertGlobalToWinNum(pwinFound, &localWindowNumber);
  65.  
  66.     while (count < [acceptViewList count])
  67.     {
  68.         currentView = [acceptViewList objectAt:count];
  69.         if ([[currentView window] windowNum] == localWindowNumber)
  70.         return currentView;
  71.     ++count;
  72.     }
  73.     return nil;
  74. }
  75.