Have the keyboard disable the mouse

  • 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.

  • You could hide mouse by

    start of layout Mouse cursor = none

  • 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.

  • here look at this demo

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • ....maybe..

  • Hey, that looks like it should work! Thanks!

    Edit: And it did. Thanks again!

  • one variable is enough...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)