Mouse messages while down

Bill Marriott wjm at wjm.org
Sat Mar 17 23:58:25 EDT 2007


Sarah,

Try this script in the card:

--
global trackMouse

on mouseDown
    put true into trackMouse
end mouseDown

on mouseMove
    if trackMouse = true then
        put "mouseMove" && the target & return after fld 1
        pass mouseMove
    end if
end mouseMove

on mouseRelease
    if trackMouse = true then
        put "mouseRelease" && the target & return after fld 1
        pass mouseRelease
    end if
end mouseRelease

on mouseLeave
    if trackMouse = true then
        put "mouseLeave" && the target & return after fld 1
        pass mouseLeave
    end if
end mouseLeave


on mouseEnter
    if trackMouse = true then
        put "mouseEnter" && the target & return after fld 1
        put false into trackMouse
        pass mouseEnter
    end if
end mouseEnter
--

I think you will find that once you press the mouse button:

- mouse down is sent to the original button
- mouseMoves are continually sent to the original button wherever you move 
the mouse
- when you release, you get a mouseRelease sent to the original button
- then a mouseMove is sent to the button you released over,
- then a mouseLeave sent to the original button,
- then a mouseEnter sent to the button you released over

- Bill

"Sarah Reichelt" <sarah.reichelt at gmail.com> 
wrote in message 
news:f99b52860703172022v513a165clb8bd9b67ffd8b158 at mail.gmail.com...
> Thanks Jim & Joe,
>
> That works OK, using a "repeat while the mouse is down loop" and then
> checking the mouseLoc to see whether it is within the rect of any of
> my 400 buttons each time.
>
> I thought this sort of polling was not considered a good idea. It
> seems fine on my 2GHz Intel Mac, but I'm not sure how it would go on
> slower machines.
>
> It still seems odd that I can't get the data I need without having to do 
> this.
>
> Cheers,
> Sarah
>
>
>
> On 3/18/07, Joe Lewis Wilkins <pepetoo at cox.net> 
> wrote:
>> Sarah,
>>
>> I don't  fully understand what you're trying to do, but something
>> like the following should get you continuous x,y that you should be
>> able to use in some manner or another to determine which button is
>> affected:
>>
>> on mousedown
>>    repeat while the mouse is down
>>      get the mouseloc
>>      -- do something with it
>>    end repeat
>> end mousedown
>>
>> Joe Wilkins
>>
>> On Mar 17, 2007, at 7:32 PM, Sarah Reichelt wrote:
>>
>> > I'm having a blank moment here and I can't work out how to solve what
>> > should be a simple problem.
>> >
>> > I have a grid of about 400 buttons and I have a mouseDown handler in
>> > the card script to detect which of these buttons is clicked first.
>> >
>> > Then I want the user to be able to drag the mouse around and I want to
>> > detect which button is under the pointer when the mouse is released.
>> > Ideally, I want to detect which button is under the pointer at all
>> > times while the mouse is down.
>> >
>> > The problem is that no other messages seem to be sent while the mouse
>> > is down (mouseEnter, mouseLeave, mouseStillDown etc). I can detect
>> > mouseRelease but "the target" is my original button so it doesn't tell
>> > me where the mouse is now. Checking "the mouseControl" in the
>> > mouseRelease handler also gives the original target.
>> >
>> > It's looking as if I may have to do some continuous polling, but I
>> > know that is generally frowned upon, so I would be grateful for any
>> > other suggestions.
>> >
>> > Thanks,
>> > Sarah
>> > _______________________________________________
>> > use-revolution mailing list
>> > use-revolution at lists.runrev.com
>> > Please visit this url to subscribe, unsubscribe and manage your
>> > subscription preferences:
>> > http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your 
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 






More information about the use-livecode mailing list