Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Matti on Mon 07/06/2021 16:44:29

Title: Disabling the mouse
Post by: 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.

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.
Title: Re: Disabling the mouse
Post by: Crimson Wizard on Mon 07/06/2021 17:03:35
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.
Title: Re: Disabling the mouse
Post by: Laura Hunt on Mon 07/06/2021 17:13:22
The way I do it is simply to add this to my Global Script's on_mouse_click function, before anything else:

Code (ags) Select
if (!mouse.Visible) return;
Title: Re: Disabling the mouse
Post by: Crimson Wizard on Mon 07/06/2021 17:59:24
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.
Title: Re: Disabling the mouse
Post by: Matti on Mon 07/06/2021 19:25:49
Thanks for the clarification.

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