Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!atncpc!bruce From: bruce@atncpc.UUCP (Bruce Henderson) Newsgroups: comp.sys.next Subject: Re: dragging an image from a button Summary: just a hack.... Message-ID: <276@atncpc.UUCP> Date: 3 Jul 90 16:41:57 GMT References: <3645@calvin.cs.mcgill.ca> Organization: Ashton Tate NCPC, San Jose, CA. Lines: 55 In article <3645@calvin.cs.mcgill.ca>, pegasus@quiche (PROVOST philippe) writes: > > greetings, > > does anyone know how to "drag an image from a button" , ie, when you select > the button with a mouse, how to move the "picture" representing the object (being > created) from the button to the document. For instance, IB do this operation > when you select a button, window....in the Palettes Window and drag that tool to > the document you define. > > Help greatly appreciated. This may not be the best way, but here it goes. First of all. The palette that you willbe dragging from should have some rather special buttons on it. The way to make them is use Icon to draw a picture of the thing that you will be dragging. In IB set the button flags to be Mom Push and set the button's Icon and Alt Icon to be the picture you just created. Of course you tehn connect the button to some target method that I will describe in a minute. What this button set up does is notify you (via the message) whenever the user clicks on that object, the button doesn't highlight and it doesn't appear to change state. (I am pretty sure this is how the IB palette works) Now, when you get the button message that you set up to be the target of your button you need to check to see if the user is dragging the mouse. (a great example of this is in Draw App's sample code) If the user is dragging, create a new window of type NX_PLAINSTYLE (this means not title bar, no border, just an empty window) the exact same size as the picture of the item (the icon you made for the button). Make sure you make the window to be NX_RETAINED, it makes it much easier. Now for the real hack. You need to track the mouse as long as it is dragged, even (I think you meant this) outside the palette window. Every time the mouse moves, you send a moveTo:: message to your little window that we just made. As if by magic you are now dragging things around the screen! As far as finding where it gets dropped, well I think you guys can figure that out (more references to Draw App source code..) but here's a hint. The target window will most likely be under where the mouse up event occurs..... I am being a bit sketchy on purpose, because If all you gizmo freaks on the net can easily reproduce what it took me a while to figure out... Well, then every peice of software will be as cool as the one we're writing! Bruce Henderson Interface KGB Aston Tate NeXTeam