Question about the sensitivity of the mouseMove message
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 43
- Joined: Fri Aug 21, 2020 7:06 pm
Question about the sensitivity of the mouseMove message
I have a stack that displays an image graphic, and I want the user to be able to interact with that image using the mouse.
Somewhat simplified, I have a 100 x 100 grid of cells, each 10 pixels square. I want to use a mouseMove handler to display the row and column numbers of the cell the mouse is over, and to have that display change in real time as the mouse moves.
My handler is mostly successful, except it seems to receive messages only after the mouse has moved about ten pixels or more. I don't seem to get a message for a mouse movement of a single pixel.
Is this the expected behavior? Or is there some interplay with some internal parameters like how often the idle message or mouseStillDown message is sent?
Somewhat simplified, I have a 100 x 100 grid of cells, each 10 pixels square. I want to use a mouseMove handler to display the row and column numbers of the cell the mouse is over, and to have that display change in real time as the mouse moves.
My handler is mostly successful, except it seems to receive messages only after the mouse has moved about ten pixels or more. I don't seem to get a message for a mouse movement of a single pixel.
Is this the expected behavior? Or is there some interplay with some internal parameters like how often the idle message or mouseStillDown message is sent?
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Question about the sensitivity of the mouseMove message
Have you logged the mouseDown events to obtain precise timings? It may be useful to know the exact interval between those messages.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Question about the sensitivity of the mouseMove message
What did you compose the grid of, is this like a field table? Or is it a grid of 100x100 different objects? Depending on the answer to that, would depend on which way I would go.PlaidFlannel wrote: ↑Tue Feb 16, 2021 7:56 amSomewhat simplified, I have a 100 x 100 grid of cells, each 10 pixels square. I want to use a mouseMove handler to display the row and column numbers of the cell the mouse is over, and to have that display change in real time as the mouse moves.
If it is grid of objects, for instance, I'd probably use mouseEnter instead of mouseMove.
Here is a stack giving a fairly decent amount of mouse information. It isn't polished by any means heh, but hopefully it is of some help.

Re: Question about the sensitivity of the mouseMove message
Hi.
Something is going on elsewhere. There should be no delay, and nothing in the way of having the mouseLoc report each single pixel change.
We need to see your stack.
Craig
Something is going on elsewhere. There should be no delay, and nothing in the way of having the mouseLoc report each single pixel change.
We need to see your stack.
Craig
-
- Posts: 43
- Joined: Fri Aug 21, 2020 7:06 pm
Re: Question about the sensitivity of the mouseMove message
Thanks to all who replied.
One responder asked, "Have you logged the mouseDown events to obtain precise timings? It may be useful to know the exact interval between those messages."
There are no mouseDown events. I'm using only mouseMove events. My interactions with the graphic are solely based on where the mouse cursor is. No clicking.
And, of course, if there are no mouseMove messages being sent for every pixel move, I can't log them with timing information.
Another responder asked, "What did you compose the grid of, is this like a field table? Or is it a grid of 100x100 different objects? Depending on the answer to that, would depend on which way I would go."
The entire grid is painted into a single image object using the painting tools under script control. That image object is the only object where user interaction is possible, and it is the only object whose script has a mouseMove handler.
Another responder said, "Something is going on elsewhere. There should be no delay, and nothing in the way of having the mouseLoc report each single pixel change.
There is no problem with mouseLoc. The problem is that if there is no mouseMove message sent, my handler is never invoked and thus it cannot get the mouseLoc.
One responder asked, "Have you logged the mouseDown events to obtain precise timings? It may be useful to know the exact interval between those messages."
There are no mouseDown events. I'm using only mouseMove events. My interactions with the graphic are solely based on where the mouse cursor is. No clicking.
And, of course, if there are no mouseMove messages being sent for every pixel move, I can't log them with timing information.
Another responder asked, "What did you compose the grid of, is this like a field table? Or is it a grid of 100x100 different objects? Depending on the answer to that, would depend on which way I would go."
The entire grid is painted into a single image object using the painting tools under script control. That image object is the only object where user interaction is possible, and it is the only object whose script has a mouseMove handler.
Another responder said, "Something is going on elsewhere. There should be no delay, and nothing in the way of having the mouseLoc report each single pixel change.
There is no problem with mouseLoc. The problem is that if there is no mouseMove message sent, my handler is never invoked and thus it cannot get the mouseLoc.
Re: Question about the sensitivity of the mouseMove message
Please show us your MOUSEMOVE handler!
Re: Question about the sensitivity of the mouseMove message
How about setting a global var with the milliseconds on mouseEnter and subtract this from the milliseconds in mouseMovePlaidFlannel wrote: ↑Tue Feb 16, 2021 5:44 pmOne responder asked, "Have you logged the mouseDown events to obtain precise timings? It may be useful to know the exact interval between those messages."
There are no mouseDown events. I'm using only mouseMove events. My interactions with the graphic are solely based on where the mouse cursor is. No clicking.
And, of course, if there are no mouseMove messages being sent for every pixel move, I can't log them with timing information.
-
- Posts: 43
- Joined: Fri Aug 21, 2020 7:06 pm
Resolved: Question about the sensitivity of the mouseMove message
The problem has been resolved.
First, in response to Klaus, here is my mouseMove handler:
The showFloater script is in a front script for the stack. It converts the location parameters to row and column, and then displays them in a floating field.
The problem I was having in my actual stack that I was having trouble reproducing in a small demo stack was simple. The image with which the user interacts was actually two stacked images: the grid lines image below and the cell contents above. Most of the cell contents are empty, some are white, and the grid image has white pixels between the grid lines.
The mouseMove message was usually being sent to the grid image, because the cell contents at the mouse location were empty. Occasionally, the cell contents were colored pixels, so the mouseMove message was sent to the cell contents image. Visually, empty cells and white cells are identical, so it was not obvious why some mouseMove messages seemed not to be sent.
The solution was simple. The cell contents image script now simply "forwards" each mouse message to the grid image, using the "send" command.
First, in response to Klaus, here is my mouseMove handler:
Code: Select all
on mouseMove pNewH, pNewV
showFloater pNewH, pNewV
end mouseMove
The problem I was having in my actual stack that I was having trouble reproducing in a small demo stack was simple. The image with which the user interacts was actually two stacked images: the grid lines image below and the cell contents above. Most of the cell contents are empty, some are white, and the grid image has white pixels between the grid lines.
The mouseMove message was usually being sent to the grid image, because the cell contents at the mouse location were empty. Occasionally, the cell contents were colored pixels, so the mouseMove message was sent to the cell contents image. Visually, empty cells and white cells are identical, so it was not obvious why some mouseMove messages seemed not to be sent.
The solution was simple. The cell contents image script now simply "forwards" each mouse message to the grid image, using the "send" command.
Re: Question about the sensitivity of the mouseMove message
Hi.
Not sure I understand"
And if there were, lose them. You should only need a single handler in the card script; no "send" need apply.
Craig
Not sure I understand"
If there are no "mouseMove" handlers below the card level, say, how were these messages being trapped and buried?The solution was simple. The cell contents image script now simply "forwards" each mouse message to the grid image, using the "send" command.
And if there were, lose them. You should only need a single handler in the card script; no "send" need apply.
Craig
Re: Resolved: Question about the sensitivity of the mouseMove message
Well, of course we meant to ALSO show that handler (showFloater).PlaidFlannel wrote: ↑Tue Feb 16, 2021 7:51 pmThe problem has been resolved.
First, in response to Klaus, here is my mouseMove handler:The showFloater script is in a front script for the stack...Code: Select all
on mouseMove pNewH, pNewV showFloater pNewH, pNewV end mouseMove
