object beneath mouseLoc?

Ken Ray kray at sonsothunder.com
Mon Jul 4 09:11:41 EDT 2011


> Never mind, cheer up!
> 
> I just set up a stack consisting of one card and an image called "gl", and a
> field called "POZ".
> 
> I put this into the card script:
> 
> on mouseMove
>     if the mouseLoc is not within the rect of img "GL" then
>        put "outwith" into field "POZ"
>     else
>        put "inwith" into field "POZ"
>        end if
> end mouseMove
> 
> and this works REGARDLESS as to whether the mouse button is DOWN or UP .
> . .  :)

Yes, this is one of the idiosyncracies of LC, going way back to when it was
MetaCard... once you mouseDown on an object, the target remains the
originally clicked object even if you ask for things like mouseControl,
mouseChar, mouseChunk, etc. The only current way is through polling during
mouseMove, which, although ugly, is usually fast enough even if you have
hundreds of objects:


on mouseMove
    if the mouse is down then
        repeat with x = 1 to the number of controls
           if the mouseLoc is within the rect of control x then
               -- do what you want to do with it
           else
               -- take some other action
           end if
       end repeat
   end if
end mouseMove

Personally I'd like to kick that concept to the curb and have all mouseXXX
function relate to where the actual mouse *is*, regardless of whether it's
state is up or down...


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/






More information about the use-livecode mailing list