Mouse Bits...

BlitzMax Forums/BlitzMax Beginners Area/Mouse Bits...

pc_tek(Posted 2011) [#1]
Hi all...am still getting to grips with BMax. 2 questions, both concern the use of a mouse for game control...

1. How can you get BMax to capture the mouse within a windowed game? IE, the pointer can only reach to the boundary of the screen size.

2. This concerns the mouse too (sort of...and only if I don't get the answer to 1.) The 'X' in the upper-right of the windows is there and active, but clicking on it does nothing! How can I change this so that the program ends when I click the 'X'?


Jesse(Posted 2011) [#2]
double post

Last edited 2011


Jesse(Posted 2011) [#3]
window close:
Repeat
   if Appterminate()  End
Forever


Last edited 2011


GfK(Posted 2011) [#4]
1. How can you get BMax to capture the mouse within a windowed game? IE, the pointer can only reach to the boundary of the screen size.
You can't, and even if you could, having the system mouse pointer trapped inside a window is a really bad idea (unless you're writing a program to annoy people).


therevills(Posted 2011) [#5]
You can't


Well you can try ;)

Const WIDTH:Int = 800
Const HEIGHT:Int = 600

Graphics WIDTH, HEIGHT

Repeat
	Cls
	DrawRect MouseX(), MouseY(), 10, 10
	If MouseX()<10 Then MoveMouse(11, MouseY())
	If MouseY()<10 Then MoveMouse(MouseX(), 11)
	If MouseX()>WIDTH-10 Then MoveMouse(WIDTH-11, MouseY())
	If MouseY()>HEIGHT-10 Then MoveMouse(MouseX(), HEIGHT-11)
	Flip
Until AppTerminate()


But you shouldnt :P


pc_tek(Posted 2011) [#6]
Ok...thanks guys. Point taken, I will find another way of scrolling about...:)


ima747(Posted 2011) [#7]
Sounds like you want to scroll the view when the mouse gets to the edge. If so a couple suggestions:

This should probably be in full screen, as then the edge is (generally) locked. Perhaps you have some other outstanding reason though (maybe a casual game, or slow enough pace to allow users to mess around between turn etc.)

I would recommend a variable movement based on distance from the border. as in between 15 to 0 pixels away from the border it moves faster the closer you get to the edge. This would make it work in a windowed mode, and also give more control in a full screen mode. This might not be possible again if say you have a ridged grid structure to all your layouts and you don't want to add an offset point and over draws, but I think it would be worth it even then.

Good luck!


xlsior(Posted 2011) [#8]
Some programs do capture the mouse (e.g. vmware, Hyper-V, virtualPC) inside the window boundaries, but it can get really annoying... If you do add this functionality, I'd suggest you make it optional behaviour in an options menu somewhere, and give a keyboard shortcut to 'release' the mouse when desired.


ima747(Posted 2011) [#9]
To followup on xlsior, it is possible as he pointed out, but also illustrates why it's frowned upon. It's alright for something that's simulating a whole computer to grab the mouse but they're simulating a whole computer which has screen limits that would normally lock the mouse and they give the user LOTS of warning and instructions on how to get back out of it.

Possible: yes
Possible without a mod of some sort in bmax: unlikely
Recommended: not without a REALLY good reason and LOTS of user warning etc. you're better off finding a cleaner solution to your underlying problem (implied scrolling at screen edges from an earlier post) than trying to overcome UI standards.


pc_tek(Posted 2011) [#10]
Hi again folks...and thanks for all the replies. I have opted instead for a right mouse click and hold-drag to scroll around. Much like what The Settlers does in-game.

It seems that locking the mouse in the app is not a good thing and extremely user-unfriendly, even with a shortcut key or menu item to get out of it.

Thanks again guys.