MouseX() and MouseY() don't update

Archives Forums/BlitzMax Bug Reports/MouseX() and MouseY() don't update

GfK(Posted 2008) [#1]
Spent ages this morning trying to figure out why my map screen automatically scrolled itself to the top left hand corner sometimes at startup. Turns out there's a problem with Blitzmax.

Graphics 800,600

While Not KeyDown(KEY_ESCAPE)
	Cls
	DrawText "MouseX:" + MouseX(),10,10
	DrawText "MouseY:" + MouseY(),10,30
	Flip
Wend


Run code, move the mouse so that when the window opens, it'll be somewhere in the 800x600 window. Then leave it still until the program starts to run.

Both MouseX() and MouseY() report 0 until you move the mouse again. It *should* start off at the actual mouse coordinates, not 0,0.


tonyg(Posted 2008) [#2]
Same here. If you add a movemouse command it helps. The mouselocation array, which mousex() and mousey() interrogates, is only updated by the EVENT_MOUSEMOVE.


Yan(Posted 2008) [#3]
It works fine here, although there does seem to be some delay before the value gets updated?

Does sticking a pollsystem immediately before or after the Graphics command make any difference?

Has this been reported before, it seems familiar?

[edit]
A quick kludge shows the delay to be consistently around 100->120ms.

If that help any. ;o)
[/edit]


tonyg(Posted 2008) [#4]
Pollsystem doesn't help and there's no change in the values even after leaving it for minutes.


GfK(Posted 2008) [#5]
What tonyg said.

I'm currently using MoveMouse as a temporary 'fix' but I don't necessarily want the mouse to move to a specific location at startup so this isn't ideal.

I thought I had reported this before but a quick search turned up nothing... unless its gone into the bug bin, but it shouldn't have considering its still a problem.

[edit] Just looked, nothing there except somebody ages ago reporting a similar problem on Mac.


MrTAToad(Posted 2008) [#6]
On the Mac here, the initial values are 0,0 - but as soon as the mouse is moved, the positions are updated straight away.


GfK(Posted 2008) [#7]
On the Mac here, the initial values are 0,0 - but as soon as the mouse is moved, the positions are updated straight away.
That's exactly what the PC version is doing. But I want the initial values to be relevant to wherever the mouse is.


Brucey(Posted 2008) [#8]
Oh. I thought that was a feature.... it's always done that :-p


GfK(Posted 2008) [#9]
Under what circumstances would you want to know where the mouse *isn't*? ;)


Brucey(Posted 2008) [#10]
It's BlitzMax... I'm never surprised when it tells you stuff you don't want to know.


MrTAToad(Posted 2008) [#11]
But I want the initial values to be relevant to wherever the mouse is

It certainly should to start with...


tonyg(Posted 2008) [#12]
This is a slightly better workaround :
Local MouseEvent:TEvent=CreateEvent(EVENT_MOUSEMOVE)
EmitEvent(MouseEvent)
'Delay 100
Graphics 800,600
While Not KeyDown(KEY_ESCAPE)
	Cls
	DrawText "MouseX:" + MouseX(),10,10
	DrawText "MouseY:" + MouseY(),10,30
	Flip
Wend



Yan(Posted 2008) [#13]
@gfk - Hmm, perhaps I'm thinking of the Mac report then.

This is weird. Am I the only person this works for?

Could one of you fellas humour me and try this with a standalone exe?


Ross C(Posted 2008) [#14]
Gfk, can't you get the mouse co-ords from windows, and set them to that? I understand it is a bug of some sort though.


MGE(Posted 2008) [#15]
I just tested this and it runs as expected. If the mouse is out of the window at program start up, mouse is 0,0. If the mouse is already inside the window at program start up, mouse x,y is reported and accurate. I'm not seeing a problem.


tonyg(Posted 2008) [#16]
I'm not seeing a problem.

What are your specs?


tonyg(Posted 2008) [#17]
Blimey, the things you find while looking for something else


MGE(Posted 2008) [#18]
Windows XP, Intel Integrated, 512mb, Intel Celeron