Deselecting Line tool

Scott Raney raney at metacard.com
Wed Feb 20 11:23:01 EST 2002


On Wed, 20 Feb 2002 cowhead <cowhead at ztv.ne.jp> wrote:

> I had to do this in a metacard project in order for users to change
> colors "mid-draw" as it were. And I didn't want to have a separate
> "control" pallette.
> 
> 1.  First establish the rect (the zone) where you want all the drawing
> to take place.
> 2.  Locate your buttons and controls outside of this rect
> 3.  Draw button script:
> 
> on mouseUp
> global zaCheckRes
> choose line tool
> send zaCheck to me in 500 milliseconds
> put the result into zaCheckRes
> end mouseUp
> 
> on zaCheck
> global zaCheckRes
> if the mouseLoc is within the rect of w,x,y,z then
> choose line tool
> else
> choose browse tool
> end if
> send zaCheck to me in 500 milliseconds
> put the result into zaCheckRes
> end zaCheck
> 
> 4.  Stop draw button script:
> on mouseUp
> global zaCheckRes
> cancel zaCheckRes
> end mouseUp
> 
> Of course, you can also change colors, line sizes and choose other tools
> this way.

There's a better way to do this, though, and as a bonus it avoids the
dreaded polling function "the mouseLoc": just use the mouseMove
message and its x,y parameters directly.  This also avoids the
half-second delay in your script which I would imagine would be a
problem for fast workers.

Note that at least in MetaCard these messages are grabbed by the
development environment when you have something other than the browse
tool chosen to keep your controls from responding to mouse clicks.
You may need to run your application without the development
environment to test.
  Regards,
    Scott

> Best of luck,
> 
> mark mitchell
> japan

********************************************************
Scott Raney  raney at metacard.com  http://www.metacard.com
MetaCard: You know, there's an easier way to do that...





More information about the use-livecode mailing list