MouseDeltaX/Y for CanvasGadget

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

MouseDeltaX/Y for CanvasGadget

Post by kenmo »

With 4.60 beta 4 I have been finally diving deep into the new CanvasGadget, and it is GREAT, thank you for it (to freak? Fred? everyone?)!

I'm just surprised that with so many EventTypes, there is no #PB_Canvas_MouseDeltaX or #PB_Canvas_MouseDeltaY, which would be very useful for dragging objects or panning a view.

Unless I have overlooked something, you can only achieve dragging by keeping track of the new and previous mouse coordinates, correct?
This isn't difficult at all, but a simple GetGadgetAttribute(Canvas, #PB_Canvas_MouseDeltaX/Y) would be awesome.

The other issue is: sometimes you want to clip the mouse to the canvas (often hide it too) but this bounds the MouseX and MouseY values, so you cannot detect mouse motion BEYOND the edges with the coordinates method. This is the situation I have run into, I want to clip and hide the mouse, but the user should be able to pan the camera "forever" with a single mouse-button-down.

(For comparison, look at MouseDeltaX() and MouseDeltaY() from the mouse library. If I recall correctly, these report mouse motion even when the x/y coordinates are actually stopped at the edge of the screen.)

Does this request make sense??
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: MouseDeltaX/Y for CanvasGadget

Post by kenmo »

Thinking more about this...

The MouseDeltaX/Y values should only update upon a MouseMove event (that is, reporting the number of x/y pixels moved since the previous MouseMove was reported).

Otherwise, say the user presses a key down while dragging the mouse: you wouldn't want the KeyDown event to "absorb" some of the delta pixels... (the user/programmer/me wouldn't be monitoring mouse moves upon KeyDown events!)

Does this request Part 2 make sense?? :lol:
Post Reply