Disabling the mouse

Started by Matti, Mon 07/06/2021 16:44:29

Previous topic - Next topic

Matti

I just realized that making the mouse cursor invisible doesn't disable the mouse and clicks are still being registered. This seems a bit weird to me and I assumed that the player can't click while the cursor is invisible.

Is there an easy way to disable the mouse alltogether? I have a non-blocking effect in one of my rooms and the player is not supposed to do anything while the effect is running. I can of course use ClaimEvent or write some condition in the Global Script. It just seems a bit unnecessary and something like Mouse.Enabled and Mouse.Disabled would be handy.

Crimson Wizard

Quote from: Matti on Mon 07/06/2021 16:44:29I can of course use ClaimEvent or write some condition in the Global Script.

This is the way currently.

Laura Hunt

The way I do it is simply to add this to my Global Script's on_mouse_click function, before anything else:

Code: ags
if (!mouse.Visible) return;

Crimson Wizard

#3
Quote from: Matti on Mon 07/06/2021 16:44:29
I just realized that making the mouse cursor invisible doesn't disable the mouse and clicks are still being registered. This seems a bit weird to me and I assumed that the player can't click while the cursor is invisible.

BTW, to clarify this, automatic handling of clicks may be disabled on some interface elements when the cursor is hidden (at least I hope it is), but mouse button presses still work as an input in other contexts. The reason for this simply is that a game does not need a visible cursor to use mouse buttons. E.g. think of an arcade game or a 1st person shooter.

EDIT: I did a quick search, and it looks like there may be still places where the engine does not care if the cursor is hidden or not. TBH I think this may be considered a bug, and should be brought to some consistency.

Matti

Thanks for the clarification.

@Laura: Thanks, that's a convenient solution :)

SMF spam blocked by CleanTalk