Mouse positioning bug?

BlitzMax Forums/MaxGUI Module/Mouse positioning bug?

sswift(Posted 2008) [#1]
I don't know if this is a bug or not, but I'm getting some weird behavior with the mouse...

I have a panel that resizes with a window. I have a canvas in the middle of the window which is 800x500. When I maximize the window the controls of my game go wonky. I have tracked it down to the mouse code in max behaving strangely.

In my app I have the following code:

MoveMouse App.Width/2, App.Height/2
	
DebugLog(App.Width/2 + "," + App.Height/2)
DebugLog(MouseX() + "," + MouseY())


When debugging I get:
DebugLog:400,250
DebugLog:760,0

In other words, MouseX and MouseY are returning coordinates in a different space than that which is used when I set the coordinates.

Furthermore, said space makes no sense. The X is almost doubled, while the Y is zeroed out.


Here's code which reproduces the "bug":




To reproduce the bug, run the above in debugmode, move the mouse around a bit, then press ALT to get back your mouse cursor, and hit the maximize button. Then move the mouse around some more, and hit ESC. You'll see the numbers don't match up anymore in the debug window after you hit maximize.


sswift(Posted 2008) [#2]
Hm... EVENT_MOUSEMOVE triggers right up until the window is maximized and then stops.


sswift(Posted 2008) [#3]
Removing the call to EnablePolledInput() seems to fix the issue with EVENT_MOUSEMOVE but that's unsatisfactory because I'd have to either duplicate all the functionality of the polledinput functions, or handle all my input in the event handler, which would not be pretty.

It seems like PolledInput may be disabled when maximizing but the enabled boolean isn't being reset properly so when I try to reenable it the error handing code disallows it.


TaskMaster(Posted 2008) [#4]
You are having problems when your window is resized? As far as I know, you have to do some reinitializing of the canvas when the window is resized. I previously had been destroying the canvas and making a new one at the new size, but somebody gave me some code that refreshed the canvas.

Here is the URL to that discussion:

http://www.blitzmax.com/Community/posts.php?topic=71535#829357

and this URL talks of resizing canvases as well:

http://www.blitzmax.com/Community/posts.php?topic=70396#787269

Hope this helps.


Otus(Posted 2008) [#5]
Same happens if you drag a border to resize the window. Whether it's a known bug or not, I'd call it one.