Keeping the mouse pointer within a window
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Keeping the mouse pointer within a window
I'm trying to keep the mouse cursor inside the boundaries of my stack. I've been messing with the screenMouseLoc property, but I can't see to figure it out. Any tips?
Re: Keeping the mouse pointer within a window
Hi sefrojonesGAda40,
Give this a try in the card script
That is only for the left you will have to figure out the other 3 sides.
Needed that "10" as a margin as the idle rate can be to slow for a really fast motion.
Mind you a function like this would really ummm upset me.
Simon
Give this a try in the card script
Code: Select all
on mouseMove newMouseH,newMouseV
if item 1 of the mouseLoc < 10 then
set the screenMouseLoc to the (Left of this stack + 10), item 2 of the screenMouseLoc
end if
end mouseMove
Needed that "10" as a margin as the idle rate can be to slow for a really fast motion.
Mind you a function like this would really ummm upset me.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Keeping the mouse pointer within a window
Thanks simon, this is only for when my gameloop is running. otherwise if a user clicks outside of the stack it loses focus, or does not operate correctly.
EDIT: this is what i ended up going with for now, it works well. Thanks Simon!
EDIT: this is what i ended up going with for now, it works well. Thanks Simon!
Code: Select all
on mousemove
if the vis of grp "getready" is false then
if item 1 of the mouseLoc < 60 then
set the screenMouseLoc to the (Left of this stack + 60), 500
set the loc of grp "player" to item 1 of the mouseloc,500
end if
if item 1 of the mouseLoc > 740 then
set the screenMouseLoc to the (right of this stack - 60), 500
set the loc of grp "player" to item 1 of the mouseloc,500
end if
if item 2 of the mouseLoc < 500 then
set the screenMouseLoc to item 1 of the screenmouseloc,500
set the loc of grp "player" to item 1 of the mouseloc,500
end if
if item 2 of the mouseLoc > 500 then
set the screenMouseLoc to the item 1 of the screenMouseLoc,500
end if
set the loc of grp "player" to item 1 of the mouseloc,500
end if
end mousemove
Re: Keeping the mouse pointer within a window
Please don't restrict the user's cursor. Really. Don't do it. It goes against every interface prohibition. Unless the user knows how to switch apps with the keyboard shortcuts (and many do not) you have restricted them to your app without any way to get out. Some novices may actually restart their machine in order to quit, and they will be convinced your app is too buggy to use.
You can't assume that people know how to navigate without a mouse. I know a Windows user who has been using his computer for years and didn't know about the keyboard shortcuts for copy/paste, he always used the mouse. Even those who do know how to switch apps will resent yours for taking away control.
It is the app's responbility to manage itself when it goes into the background. See the suspendstack message in the dictionary, it tells you when your app loses focus so that you can take any required actions. Resumestack triggers when the app receives focus again, so that it can do whatever is required to resume the game. If you need help with that, we're here.
You can't assume that people know how to navigate without a mouse. I know a Windows user who has been using his computer for years and didn't know about the keyboard shortcuts for copy/paste, he always used the mouse. Even those who do know how to switch apps will resent yours for taking away control.
It is the app's responbility to manage itself when it goes into the background. See the suspendstack message in the dictionary, it tells you when your app loses focus so that you can take any required actions. Resumestack triggers when the app receives focus again, so that it can do whatever is required to resume the game. If you need help with that, we're here.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Keeping the mouse pointer within a window
The user is able to show the cursor/ end the game with the escape key. Since this is an action game, and the cursor will be hidden during gameplay, I don't really think it's a big deal. Is it?
Re: Keeping the mouse pointer within a window
Maybe 10 years ago it was OK -- before the mouse got popular and computers were not used by everyone. Use of the mouse is so ingrained into the average users habits they tend to panic if their mouse doesn't move when they want it to.sefrojonesGAda40 wrote:The user is able to show the cursor/ end the game with the escape key. Since this is an action game, and the cursor will be hidden during gameplay, I don't really think it's a big deal. Is it?
They also do not know what the escape key was designed for.
Most apps these days will not exit with the escape key so users probably have no experience with it.
The mouse rules them all...
Paul
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Keeping the mouse pointer within a window
Thanks for the input guys, I think the way to go is with the suspendstack, and resumestack, and just pause the stack when it loses focus.
I will reply when I've got it worked out.
I will reply when I've got it worked out.