Dragging Lines in a Field

Tariel Gogoberidze PMDA at earthlink.net
Tue Apr 23 15:47:00 EDT 2002


 
> Message: 1
> Date: Mon, 22 Apr 2002 11:30:52 -0600 (MDT)
> From: Scott Raney <raney at metacard.com>
> Subject: Re: Dragging Lines in a Field

> > MC 2.4.2  was eventually quitting with "application quit unexpectedly"
> > error on Mac
> 
> Seems 100% reliable here.  Is there something else you have to do to
> get it to fail?  Sure you weren't causing some sort of recursion by
> making a call in mouseStillDown that didn't exit?

I can NOT replicate it any more, but since then I  replaced MC 2.4.2B4
with latest gamma.
The script that was causing MC to quit is at  the end of this post. The
symptom was that mousestilldown was still  working after the mouse was
up. It was  calling MouseStillDown until the mouse was clicked outside
the field. 

> > So, I  changed  script   to.
> >
> > local Actionflag
> > on mouseDown --  mouseDown is used to select  lines in field with list behavior
> >   put "false"  into  Actionflag
> > end mouseDown
> >
> > on MouseStillDown -- this  will initiate "Drag line" but will work only  once
> >   if Actionflag is "false"  then
> >     put "true"  into  Actionflag -- so it never do it again until the
> > mouse is down
> >     Send "dragLine" to me in 1 milliseconds
> >   end if
> > on MouseStillDown
> 

> This is kind of the worst of both worlds too: that MouseStillDown
> message is sent repeatedly as long as you've got the mouse down.  So
> now you've got two sets of messages, neither of which are doing the
> right thing which is to monitor the actual movements of the mouse
> rather than periodically and repeatedly polling it.

> 
> > on dragLine
> >   if  the mouse is up  then
> > -- do final routine and  exit
> >      exit dragLine
> >   else
> > -- drag the lines in  field
> >    send dragline to me in 10 milliseconds
> >    end if
> > end dragline
> >

> > This  effectively  avoids using  "repeat until the mouse is whatever"
> > and uses  mouseStillDown only once  to trigger dragLine  script
> 
> No, it uses the mouseStillDown message *in addition to* send ... in
> for as long as the mouse is down.

I definitely  may be wrong but MouseStillDown sends messages anyway when
 the mouse is still down - right?. It is if/then  condition there that
triggers  "on Dragline" handler  only  once, all farther  calls to
MouseStillDown are not executed. If it is not so, I would definitely
love to learn first hand what is wrong in my  assumption and how it
works internally.

If I would use MouseMove I still need to put condition "if the mouse is
Down" and we are back to square one.

On  mouseMove
IF the  mouse  is DOWN  then --  back  to mouse function use
-- drag line
end IF

> > I'm  not so sure it is *always* possible to find  alternative  to
> > MouseStillDown and  "repeat until  the mouse whatever". May be  it IS
> > always  possible but I'm  not  sure.
> 
> Trust me, it is.

>   Regards,
>     Scott
>

Then we  are back to Richard Gaskin  question:

"So the alternative handler you're suggesting looks like...?"

 Below is original script posted by Ray Horsley for reference 
It has some minor modifications

Conditions: MouseDown is needed  to just select  line in  field with
list behavior. Something should detect that  mouse is  still down and
trigger the  script that will drag the line until the mouse is up.

on MouseStillDown
## button "DragLineBtn" has show border false; fld has  list  behavior.
  put the ClickLine into CkLn
  put value(the ClickLine) into moveTxt
  if moveTxt is empty then exit MouseStillDown
  delete line (word 2 of CkLn) of me
  set the label of button "DragLineBtn" to MoveTxt
  put the textHeight of me into linHt
  --
  put 4 into  MyTune
  -- don't know  why but on my computer (Mac) it needs this correction
to look precise
  --
  set the borderWidth of button "DragLineBtn" to the margins of me - MyTune
  put the top of me into MyTop
  put (the left of me) + MyTune into MyLeft
  if the vScrollbar of me is "true" then
    set the width of button "DragLineBtn" to (the width of me) - (the
scrollbarWidth of me) - (MyTune*2)
  else
    set the width of button "DragLineBtn" to (the width of me) - (MyTune*2)
  end if
  set the height of button "DragLineBtn" to LinHt
  set the topLeft of button "DragLineBtn" to MyLeft,MyTop
  set the visible of button "DragLineBtn" to true
  repeat until the mouse is up
    put the MouseV into VertiMouse
    put the scroll of me into temp
    if VertiMouse < MyTop then
      put MyTop into VertiMouse
      subtract LinHt from temp
    end if
    if VertiMouse > the bottom of me then
      put the bottom of me into VertiMouse
      add LinHt to temp
    end if
    set the scroll of me to temp
    set the topLeft of button "DragLineBtn" to MyLeft,VertiMouse-(LinHt
div 2)
  end repeat
  set the visible of button "DragLineBtn" to false
  put ((VertiMouse - MyTop) div linHt)+1 into CurLinPtr
  if the scroll of me > 0 then
    add (the scroll of me div LinHt)  to CurLinPtr
  end if
  if CurLinPtr > (number of lines in me) then
    put cr&moveTxt after the last line of me
    select the last line of me
  else
    put MoveTxt & cr before line CurLinPtr of me
    select line CurLinPtr of me
  end if
end MouseStillDown
 
Best  Regards
Tariel Gogoberidze



More information about the metacard mailing list