MouseZSpeed()<>0 when window looses its focus

Archives Forums/BlitzMax Bug Reports/MouseZSpeed()<>0 when window looses its focus

Lobby(Posted 2011) [#1]
If you're working with MouseZSpeed() in a BlitzMax window, to zoom for instance, so you'll see that this function returns a value smaller or greater than 0 if you leave the window without escaping it (You have to used the mousewheel already in the window to see this effect).

This bug is caused in brl.polledsystem which runs everytime when the window is suspended the function FlushMouse. That's good, but let's have a look into this function:
Function FlushMouse()
	PollSystem
	For Local i=0 Until 4
		mouseStates[i]=0
		mouseHits[i]=0
	Next
	mouseLocation[2]=0
End Function

You can see, that it also resets the MouseZ location. Now take a look into the function MouseZSpeed() and you can see the problem:
Function MouseZSpeed()
	If autoPoll PollSystem
	Local d=mouseLocation[2]-lastMouseLocation[2]
	lastMouseLocation[2]=mouseLocation[2]
	Return d
EndFunction

MouseLocation[2] will be 0 now while lastMouseLocation[2] weren't reseted so that the function will return a value without any mouse wheel movement.

To fix that issue you could comment the reset of MouseLocation[2] out:
Function FlushMouse()
	PollSystem
	For Local i=0 Until 4
		mouseStates[i]=0
		mouseHits[i]=0
	Next
	'mouseLocation[2]=0
End Function


I don't understand why you let FlushMouse reset the mouse z position, but I hope you'll correct this to avoid these horrible MouseZSpeed() results.