Clicking on linked text sends a mouseLeave message?

Wilhelm Sanke sanke at hrz.uni-kassel.de
Fri Jul 25 14:17:02 EDT 2003


On Thu, 24 Jul 2003 Jim Hurley <jhurley at infostations.com> wrote:

> The  script below allows students to click on various words
> ("objective lens", "ocular lens" etc.) in a "Help field" and an arrow
> is drawn from the linked word or phrase to the object in question.
>
> But I want the arrow to go away (set the points of graphic "arrow" to
> empty) when the the mouse leaves the  field.
>
>   But my handler "mouseLeave" beeps every time I click on a link, the
> arrow flashes but immediately disappears.
>
> Why should clicking on a link send a mouseLeave message?
>
> If I omit the mouseLeave handler, the arrow appears and stays as it
> should. (But of course it doesn't go away when the mouse leaves the
> field.)
>
> on mouseUP
>    if there is no graphic "arrow" then
>      set the style of the templateGraphic to "line"
>      set the endarrow of the templateGraphic to true
>      set the lineSize of the templateGraphic  to  2
>      create graphic "arrow"
>    end if
>
>    put the mouseLoc into line 1 of tGraphicPoints --Set the start
> point of the arrow
>    put the clicktext into what
>
>    switch what
>    case "objective lens"
>      put 869,217 into line 2 of tGraphicPoints -- Set the end point
>      break
>    case "ocular lens"
>      put 545,263 into line 2 of tGraphicPoints
>      break
>    case "focal point"
>      put 435,327 into line 2 of tGraphicPoints
>      break
>    default
>      put "" into line 2 of tGraphicPoints
>      break
>    end switch
>    set the points of graphic "arrow" to tGraphicPoints --Draw the arrow
>    send "choose the browse tool" to me in 1 tick
> end mouseUp
>
> on mouseLeave
>    beep
>    set the points of graphic "arrow" to ""
> end mouseLeave
>

Apart from Jacqueline´s suggestions and your workarounds

> >You could work around it by not using the mouseloc as the start of the
> >arrow. Add a few pixels to the horizontal position, for example.
> >(Although if the user moves the mouse over the graphic, the graphic will
> >disappear again.)
> >
> >--
> >Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> >HyperActive Software           |     http://www.hyperactivesw.com
> >
>
> Jacqueline,
>
> I never would have guess this resolution. Knowing what the problem is
> I can work around it. The following is clumsy but it works:
>
> on mouseLeave
>    put 2 into tMargin
>    put the mouseV into tY
>    put the mouseH  into tX
>    if tX - tMargin < item 1 of the rect of me or tY - tMargin < item 2
> of the rect of me then
>      set the points of graphic "arrow" to ""
>    end if
>

there is still another simple solution. Leave the mouseup handler of
your first script (of Thursday) exactly as it is. Delete the mouseleave
handler.
Place a transparent field on top of your "Help" field. Put the following
script into the transparent field and put the mouseleave handler here,
too:

"on mouseUp
  put the mouseloc into MLoc
  lock screen
  hide me
  click at MLoc
  show me
  unlock screen
end mouseUp

on mouseLeave
  set the points of graphic "arrow" to ""
end mouseLeave"

Using "lock screen" could be also left out, it only prevents the
linktext to change colors.

I have used the technique of clicking at a transparent field and then
hiding it for a moment on several occassions, last time in a game stack
I sent to User Contributions three weeks ago, but which has not yet made
it to the website.

Regards,

Wilhelm Sanke





More information about the use-livecode mailing list