MouseX() and MouseY() don't updateBlitzMax Forums/BlitzMax Bug Reports/MouseX() and MouseY() don't update
| 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.
| 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. |
| 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?
A quick kludge shows the delay to be consistently around 100->120ms.
If that help any. ;o)
| Pollsystem doesn't help and there's no change in the values even after leaving it for minutes. |
| 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.
 Just looked, nothing there except somebody ages ago reporting a similar problem on Mac.
| On the Mac here, the initial values are 0,0 - but as soon as the mouse is moved, the positions are updated straight away. |
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.
| Oh. I thought that was a feature.... it's always done that :-p |
| Under what circumstances would you want to know where the mouse *isn't*? ;) |
| It's BlitzMax... I'm never surprised when it tells you stuff you don't want to know. |
But I want the initial values to be relevant to wherever the mouse is
It certainly should to start with...
| 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
| @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?
| 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. |
| 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. |
I'm not seeing a problem.
What are your specs?
| Blimey, the things you find while looking for something else |
| Windows XP, Intel Integrated, 512mb, Intel Celeron |