Maybe this is a really basic question, but I’ve never noticed it until today:
The MouseMove event does not fire while the mouse button is being held down and the mouse being moved within the control. So for example, with a slider, if you grab the slider and start moving the mouse, MouseMove does not fire. MouseDrag fires if you return true from MouseDown, but MouseMove doesn’t.
Is this correct and expected behavior? I thought MouseMove fired regardless?
not when you are doing a drag
OK. So here’s the deal. I would like to get get the Y position of the cursor in a slider (actually, it’s one of your UltimateSlider controls, Karen) when I am moving the slider. I have a text label that I want to move along with the slider.
If I return true in MouseDown, MouseDrag works, but then the slider doesn’t. If I check for System.MouseDown in the MouseMove event, it doesn’t work either. So I’m stuck trying to update the label position in one of the other events. But no other events give the mouse position so I have to use System.MouseY and it’s not always giving me what I want.
I’m open to suggestions…
Mouse coordinates in mousedown/up/drag/etc are relative coordinates from the top left corner of the window. System.mouseY gives the absolute coordinates from the top left corner of the screen so Y and system.mouseY will not be equal unless the window is placed in the top left corner of the screen. To convert the System.mouseY and System.mouseX into coordinates local to the window like you get in a mousedown event you must subtract Window.top and Window.left from the System.mouse coordinates.
Check System.MouseY in the mouse move event so you can see what it’s giving you. It should be that the Y position being reported in mouse move is System.MouseY - Window.Top
(What Jason said)
Yeah, I know. I would just be easier to get the coordinates inside the window directly. So that’s what I will do. Just didn’t know if there was some other way I was missing that was right in front of me.
Instead of doing this in the MouseDrag event, you might be able to use a short period timer, maybe 50ms, and just update the position of the label there.
Not that it answers your actual question, but if you want it tied to the slider, why not use the slider’s ValueChanged event? You know the coordinates of the slider and the min/max, so you could do it there…