Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Border for mouse in windows

Author
Message
Q and A but mostly Q
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location:
Posted: 27th Sep 2008 20:09
In the code below I set my window on and the layout I want, positioned it on the screen where I want and now what I am trying to do is to make it so when I have the mouse pass the window in any direction, like the screen height() or width or passed 0, it should return to that spot. For example if I had the mouse pass screen height() it should go right back to the screen height, so basically you cant move the mouse out of the window area. Ive tried different code and searched but no luck, just cant get it to work. Any help would be appreciated, thanks for your time!

One more problem that I would like to adress while solving this problem is the fact that the third person view should act the same so even if the mouse is stuck at the border of the screen and the mouse is still being dragged, the camera will still be moveing as it is running in the code above.
Garion
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location: Poland
Posted: 28th Sep 2008 12:20 Edited at: 28th Sep 2008 12:24


try this out, perhaps
Q and A but mostly Q
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location:
Posted: 28th Sep 2008 20:38

I tried that and it didnt work. It didnt stop the mouse from going outside the screen and it stopped the camera from working entirely.
RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 30th Sep 2008 14:34
I first thought this would work:


but if you print MouseX() and MouseY() to the screen you will see:
0<MouseX()<Screen Height()
0<MouseY()<Screen Width()

for example for 800x600 this means that MouseX() is a number from 0 to 799 but never <0 or >800.

so i tried this:

but as you will see Position Mouse positions the mouse on the whole screen, not the window. So we hawve to add the window position to the values. As you use "set window position 300,300" earlier in the code its really easy. But the new code doesnt work either:

So... now im stuck too... i hope i gave you some tips... but you'll be best off to make it fullscreen or just position the mouse in the middle of the screen all the time (mouseMoveX/Y will work anyways).

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 30th Sep 2008 21:55
Here you go.



You can make it faster by fully integrating in your code, but this is easier to read...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2024-09-27 20:22:45
Your offset time is: 2024-09-27 20:22:45