Have the keyboard disable the mouse

Get help using Construct 2

Post » Mon Nov 10, 2014 6:54 am

In my game, I have several menus that can be navigated with either keyboard or mouse. You can move the menu cursor by pressing the directional keys to move and Enter to select, or moving the mouse and clicking on the chosen option.

The trouble is, if the mouse cursor is sitting on top of a menu item, then the game will think you're trying to select it with the mouse, and if you press the arrow keys you'll just go right back to the one under the mouse.

What I'd like to do to fix this is to somehow disable the mouse (like setting a flag on the menu cursor) when you press any key on the keyboard, and have the menu ignore it, but then re-enable the mouse as soon as the mouse cursor moves.

The trouble is, there doesn't seem to be an "On mouse moved" event. How do I pull this off without it?

You can try out the menus in the game (or just play the game, heh) here. One of the menus in question is on the title screen. Put your mouse over an item and try to move off of it using the arrow keys.
B
10
S
2
Posts: 104
Reputation: 1,140

Post » Mon Nov 10, 2014 8:18 am

You could hide mouse by

start of layout Mouse cursor = none
B
257
S
43
G
15
Posts: 1,993
Reputation: 41,537

Post » Mon Nov 10, 2014 3:21 pm

Yeah, I do that for the actual gameplay. The trouble is not how I will disable the mouse but how I will tell that it needs re-enabling.
B
10
S
2
Posts: 104
Reputation: 1,140

Post » Mon Nov 10, 2014 4:15 pm

here look at this demo
You do not have the required permissions to view the files attached to this post.
B
257
S
43
G
15
Posts: 1,993
Reputation: 41,537

Post » Mon Nov 10, 2014 5:34 pm

You don't seem to get what I'm asking.

I know how to hide the cursor. I know how to tell when the user is using the keyboard. What I don't know is how to tell when the mouse moves.

I want the mouse to re-enable when it moves. That's what I want to know. How do I tell when the mouse is moving so I can stop ignoring it?
B
10
S
2
Posts: 104
Reputation: 1,140

Post » Mon Nov 10, 2014 5:55 pm

....maybe..
You do not have the required permissions to view the files attached to this post.
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Mon Nov 10, 2014 6:59 pm

Hey, that looks like it should work! Thanks!

Edit: And it did. Thanks again!
Last edited by MoscowModder on Mon Nov 10, 2014 7:46 pm, edited 1 time in total.
B
10
S
2
Posts: 104
Reputation: 1,140

Post » Mon Nov 10, 2014 7:20 pm

one variable is enough...
You do not have the required permissions to view the files attached to this post.
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 38 guests