Page 1 of 1

Mouse coordinates shifted in GUI

Posted: Wed Jan 31, 2007 3:44 pm
by greenya
I have noticed that Y-coordinate of mouse is shifted ( coordinates that receive IrrLicht engine from the OS ).

I creating a simple dialog box and to close it i have to click on OK button lower of its rectangle by 10-15 pixels. The same thing with moving of the window -- i can move it by clicking on the bottom edge +10 pixels down.

All GUI elements shows OK, but respond on mouse with shifted coordinates.
IrrLicht's "UserInterface" example works just OK.

Besides to select node i have to use "+15" pixels; here is my select-node code:

Code: Select all

ISceneNode* selnode = Game.SceneCollision->getSceneNodeFromScreenCoordinatesBB(
    position2d<s32>(
        Game.Device->getCursorControl()->getPosition().X,
        Game.Device->getCursorControl()->getPosition().Y+15
    )
);
One more thing: this artifact is present only in windowed mode, so if i running in full screen -- all works just fine.

Does anybody know what it could be ?

read you code again

Posted: Wed Jan 31, 2007 5:45 pm
by harukiblue
I think it may just be that you are adding 15 to the y axis

Code: Select all

Game.Device->getCursorControl()->getPosition().Y+15 
try this:

Code: Select all

Game.Device->getCursorControl()->getPosition().Y

Re: Mouse coordinates shifted in GUI

Posted: Wed Jan 31, 2007 5:54 pm
by sio2
greenya wrote: One more thing: this artifact is present only in windowed mode, so if i running in full screen -- all works just fine.

Does anybody know what it could be ?
Sounds suspiciously like the height of the Windows caption bar - which you don't get fullscreen. Perhaps a bug? Needs some investigation...

Posted: Wed Jan 31, 2007 6:54 pm
by greenya
i just checked all again. in fullscreen i have the same problem. so it is not depends on windowed/fullscreen mode.

2harukiblue
no.
the point is that if i use "+15" --- it pick correctly; if i will write without "+15" ( as it must be ) it will get object on nearly 10-15 pixels down.

also the point is that i can solve problem with picking objects ( by "+15" value ), but i cannot solve the problem with GUI -- IrrLicht engine doesn't allow me to correct mouse-coordinates-values ( -- that is normal of cause, because GUI is fully automated ), BUT this problem really disappointing me :(

Posted: Sat Feb 03, 2007 9:06 am
by bitplane
Two bugs that spring to mind-
1) are you setting a viewport before drawing the GUI?
I've got a note here reminding me to investigate GUI picking when a viewport is set, but haven't looked into it yet. Try setting your viewport to the full screen when you draw the GUI.
2) does the operating system resize the window because the screen isn't big enough? this causes mouse picking to get messed up until the window is resized again. this bug happens in both the windows and linux devices, and probably the mac one too

Posted: Sat Feb 03, 2007 2:27 pm
by drac_gd
I had to make changes to make to cursor position correct when resizing and the window is a child of another window. In my case a child control on a dialog in MFC.
If you want to look at or use my files here they are.
http://www.tronacom.com/downloads/CIrrDeviceWin32.h
http://www.tronacom.com/downloads/CIrrDeviceWin32.cpp

BTW If you can afford or get your hands on ExamDiff Pro it makes viewing and editing differences in code much easier than other merge tools I have used. ( No I am not a salesman or get a commision I just like the tool )

Posted: Wed May 16, 2007 1:56 pm
by cvf
I have the same problem in my window:

Image Image
Image Image

I have checked the mouse coordinates I get, and the size of the view with:

Code: Select all

GetWindowRect
getViewPort
getScreenSize
but all seems to be OK, and the size of the view is the same with the 3 functions above...

The offset seems to change when I move the camera and the position of the mouse... This doesn't happen in all cases, before moving the camera all the nodes work perfectly in all zones of the screen. This seems to happen only after moving the camera...

Your code at:
http://www.tronacom.com/downloads/CIrrDeviceWin32.h
http://www.tronacom.com/downloads/CIrrDeviceWin32.cpp
doesn't solve the problem...

Any ideas? Thanks in advance,

Hugo

Posted: Thu May 24, 2007 3:59 pm
by cvf
I have found the solution to this problem. I posted it at:
http://irrlicht.sourceforge.net/phpBB2/ ... 895#117895

The problem is the line: cam->setFarValue(10000000.0f);