home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!ames!bionet!raven.alaska.edu!acad3.alaska.edu!sxmlk
- From: sxmlk@acad3.alaska.edu (KIENENBERGER MIKE L)
- Newsgroups: comp.sys.next.programmer
- Subject: Re: Drag and Drop in < NS3.0
- Summary: Drag and Drop in < NS3.0
- Message-ID: <18AUG199203332039@acad3.alaska.edu>
- Date: 18 Aug 92 11:33:00 GMT
- References: <1992Aug17.104453.11070@monu6.cc.monash.edu.au>
- Sender: news@raven.alaska.edu (USENET News System)
- Organization: University of Alaska - Fairbanks
- Lines: 63
- News-Software: VAX/VMS VNEWS 1.41.UAC
- Nntp-Posting-Host: acad3.alaska.edu
-
- In article <1992Aug17.104453.11070@monu6.cc.monash.edu.au>, ede978e@monu6.cc.monash.edu.au (Robert D. Nicholson) writes...
- >I have to implement Drag and Drop behaviour in NS2.1, but I would also like
- >to know wether NS3.0 can do it properly. (Look forward to reading the
- >article on it simson)
- >
- >OK, I would like to know wether drag and drop can be implemented such that
- >the application can determine specifically which window is under the cursor.
- >
- >ie. if there are overlapping windows, I must be able to tell which is at the
- >top. ie. above all the rest
- >
- >Anybody done this?
-
- Yes! (Finally.)
- The key is the little-known postscript operator "findwindow."
-
- <x> <y> <place> <otherwindow> findwindow <x'> <y'> <window> <bool>
-
- (If you're planning on writing your own routine, note that <otherwindow>
- is a local window, while <window> is a global window! If it seems inconsistant
- to you, you are not alone!)
-
- Here's how I implemented it. "currentPoint" is in screen coords. "dragWindow"
- is the id of the window holding the image being dragged. (I want a window UNDER
- what is being dragged.) "acceptViewList" is a list of accepting views.
- The id of the first accepting view under the point is returned. If no
- accepting view is found, nil is returned.
-
- Many thanks to John Immordino at NeXTedge Developer Support who pointed out
- findwindow to me when I really needed it!
-
- 26-line routine follows.
- =============================================================================
- -Mike Kienenberger SXMLK@ALASKA (BITNet)
- University of Alaska Computer Network SXMLK@acad3.alaska.edu (Internet)
- University of Alaska-Fairbanks
- =============================================================================
-
- - checkForAcceptView:(NXPoint *)currentPoint under:dragWindow
- {
- int count = 0;
- id currentView;
- unsigned int localWindowNumber;
- float dummy;
- int pwinFound;
- int pdidFind;
-
- PSfindwindow(currentPoint->x, currentPoint->y,
- NX_BELOW, [dragWindow windowNum],
- &dummy, &dummy, &pwinFound, &pdidFind);
- if (0 == pdidFind) return nil;
-
- NXConvertGlobalToWinNum(pwinFound, &localWindowNumber);
-
- while (count < [acceptViewList count])
- {
- currentView = [acceptViewList objectAt:count];
- if ([[currentView window] windowNum] == localWindowNumber)
- return currentView;
- ++count;
- }
- return nil;
- }
-