From: drennan@acfcluster.nyu.edu (XIXAX)
Newsgroups: comp.sys.mac.hypercard,comp.sys.mac.misc,comp.sys.mac.apps
Subject: Re: Supercard: Dragging objects in Browse mode
Date: 23 Jul 92 04:52:05 GMT
Organization: New York University

In article <1992Jul21.143452.12628@news.cs.brandeis.edu>, slanka@chaos.cs.brandeis.edu (Ishantha Lokuge) writes:
> 
> Hello!
> 
> I've written script to drag a graphic object while in Browse mode
> but the speed is quite slow and there is a time lag between the mouse moving
> and the graphic moving. I do the following:
> 
> On mouseStilldown
>    Global X,Y    /* Displacement of object to mouse loc*/
>    put mouseH() - X into X1
>    put mouseV() - Y into Y1
>    move graphic ZZZ to X1,Y1 jump 1
> End MouseStilldown
> 
> 
> I would greatly appreciate if anyone out there has a better soulution
> for moving quite complex (grouped) graphic objects fast, while the mouse
> is down and is moving. Thanks a lot for any suggestions.
> 
> -Ishantha.
> 

Ishantha,

First, you are discovering why the Apple user interface suggests that we drag
the outline of the object around instead, or the outline of the enclosing
rectangle, the way the Finder does.

On older and slower Macs, even dragging an icon graphic in real-time would be
slow and sluggish.

Your method of dragging is one of a variety of possibilities. 

Another approach, which would speed things up, would be to go into a loop and
stay there while the graphic is being dragged. Your current method takes on
the overhead of handling idle messages, and invoking XCMDs, between every
movement.

Try something like this...  (off the top of my head)

--------------------------------------------------

on mouseDown
  -- Calculate the diff between the cursor
  --   and the center of the graphic.

  put item 1 of the loc of grc bigGraphic - 
      item 1 of the mouseLoc into xOffset
  put item 2 of the loc of grc bigGraphic - 
      item 2 of the mouseLoc into yOffset

  -- Loop continuously

  repeat until the mouse is up
    set the loc of grc bigGraphic to 
      item 1 of the mouseLoc + xOffset,
      item 2 of the mouseLoc + yOffset
  end repeat

end mouseDown
--------------------------------------------------

I'm sure I probably have the plusses and minuses reversed, knowing Murphy's
Law.:)

Also, when it comes to mouseDown actions, such as dragging the grow box of a
window, or pulling down a menu, it is common for any software to go into a
loop which consumes all of the processor, and does not give any time to any
other task or processes.  This helps speed the responsiveness. Most mouseDown
actions are very brief.

Should you decide to try dragging the enclosing rectangle instead, you can
use the DragRect external from the "Support Tools Externals 1.2.5" stack from
Apple, or FullDrag from Rinaldi, or others I have seen.

I think another method is available. When we are in the "edit" mode in
SuperCard, and we drag around a complex draw graphic, SuperCard automatically
draws the gray outlines of all the objects, to aid the visual positioning of
the graphic. There is a way to invoke that same action under script control. 

Unfortunately, I don't have the opportunity to try it out for you to make
sure I'm not dreaming. :)

Hope this helps.

Mark Hanrek
America Online SuperCard SIG Leader
hanrekm@aol.com
Newsgroups: comp.sys.mac.hypercard