Drag and Drop
J. Landman Gay
jacque at hyperactivesw.com
Mon Feb 7 20:29:00 EST 2011
On 2/7/11 7:07 PM, Peter Haworth wrote:
> And, as someone else pointed out, the mouseStack
> property does NOT correctly report the name of the stack that the
> mouse is over unless you are in a mouseUp handler, or at least it
> didn't in Scott's handler. Sorry to keep harping on this, but the
> dictionary, yet again, is flawed.
If that's so, then it sounds like the mousestack property is only
updated on idle. I know that's true of lots of other properties. If your
dragging handler uses a "repeat until the mouse is up" structure, you
aren't giving any time to the engine and lots of things won't get
updated. It's a good argument for using "send" instead. Repeat loops are
slow and memory hogs too.
> I found the IDE code that handles the drag and drop of controls from
> the Tools palette. It figures out which stack the mouse is over by
> comparing the mouse location to the rectangle of each open stack. So
> I did the same thing and it works fine. I hope I'm not breaking any
> intellectual property laws.
Nope, it's not only fine, it's encouraged. That's why RR leaves the
scripts unlocked. It's a great way to learn.
> I'm left with one strangeness. As a control is being dragged, it has
> a blue background. After it is copied to the new stack, it still has
> a blue background until I click on it, then it goes back to the
> background of the original control. I noticed that happening in
> Scott's script (except it's green instead of blue). Not a big deal
> but Scott, wondering if you might have a fix for that?
If a script sets any properties of the template object, then all new
controls of that type will also use those properties until the template
is reset. Use "reset the template<whatever>" before creating a new
control to revert it back to the default values. I.e., for a field,
"reset the templatefield".
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the Use-livecode