Cursor questions
Andre.Bisseret
Andre.Bisseret at inria.fr
Fri Mar 19 12:03:09 EDT 2010
Bonjour,
Le 19 mars 10 à 13:15, Peter Brigham MD a écrit :
>
> On Mar 18, 2010, at 6:56 PM, Sarah Reichelt wrote:
>
>>> Second, is it possible for me to detect that the mouse is over a
>>> link and change the cursor to something else (i.e. the hand icon/
>>> cursor)? I know there's changes coming w/ 4.5 that look promising.
>>> I haven't bothered to download the developer preview as I really
>>> don't want to risk is, but if some of these concerns go away with
>>> 4.5 and someone can just email me them (instead of breaking NDA on
>>> the list), that'd be fine, too. (massung at gmail.com).
>>
>> This doesn't require 4.5, so no NDA conflict here.
>>
>> I put this in a card script and it seems to work fine:
>>
>> on mouseMove
>> if word 1 of the target = "field" then
>> if the textStyle of the mouseText contains "link" then
>> lock cursor
>> set the cursor to hand
>> else
>> unlock cursor
>> end if
>> end if
>>
>> pass mouseMove
>> end mouseMove
With browse tool choosen the handler above works perfectly, but not
if pointer tool is choosen: in this case one gets errors (for the
second "if" line).
To avoid that,, seems that is necessary to include the case where the
mouseText is empty.
Something like the following:
on mouseMove
if word 1 of the target = "field" then
if the mouseText = empty then unlock cursor
else
if the textStyle of the mouseText contains "link" then
lock cursor
set the cursor to hand
else
unlock cursor
end if
end if
end if
pass mouseMove
end mouseMove
By the way, generally I am using the following (thanks to the help of
Éric Chatonet) which include the case of buttons and which works well
local tCode,
---------------------
on mouseMove
switch
case "button" is in the target
ShowHandCursor #
break
case the mouseText = empty --mouseText = empty -- important!
unlock cursor
break
case "link" is in the textStyle of the mouseChunk
ShowHandCursor #
break
default
ResetCursor #
end switch
end mouseMove
------------------------------
on mouseLeave
ResetCursor #
end mouseLeave
------------------------------
on ShowHandCursor
set the cursor to hand
lock cursor
end ShowHandCursor
------------------------------
on ResetCursor
unlock cursor
end ResetCursor
>
> I prefer to set the defaultcursor to hand or to empty instead of
> locking and setting the cursor. Whenever I've tried to use lock
> cursor I've ended up having intermittent frozen cursor problems.
did not notice such issue, but well, I am going to pay attention to
this
> Also, you might want to put in a "if the locktext of the target
> then..." test, or you'll get the cursor changing over links in
> unlocked fields, and when the cursor changes to hand the user will
> think the link is clickable -- but it won't be.
>
> -- Peter
>
Thank you Peter for this goog suggestion. I will keep it in mind if I
have links in unlocked fields
You seem very and rightly "user-orented" ;-))
Best regards from Grenoble
André
More information about the use-livecode
mailing list