Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Baguettator on Sat 20/03/2021 14:57:03

Title: Click outside the windowed mode problems
Post by: Baguettator on Sat 20/03/2021 14:57:03
Hi !

I encounter a problem : when in windowed mode, if I click outside the game (so outside the window of the game), it results in an event I scripted in on_key_press : "if (keycode==eKeyS)".

Normally, if I put the S key, it shows a message at the screen (it is like a cheat code for play-testing). And when I click outside of the screen of the game, this message appears.

An idea ?
Title: Re: Click outside the windowed mode problems
Post by: Crimson Wizard on Sat 20/03/2021 15:25:16
Never heard of such problem before. AGS is not supposed to even receive any key presses when the input focus is elsewhere.

Does the message appear right after you click or when you alt+tab back to AGS window?

Have you tried giving it out for testing to someone else to see if it happens there too?
Title: Re: Click outside the windowed mode problems
Post by: Baguettator on Thu 01/04/2021 10:37:31
Sorry for delay for answering, I got some other people testing this issue, and at the moment I don't know if AGS reacts to a key press when it is ALT TAB, or when someone clicks elsewhere the window mode... I didn't get the issue, another people said it to me. I'm going to inspect it deeper :)
Title: Re: Click outside the windowed mode problems
Post by: Baguettator on Wed 02/06/2021 12:45:34
Hi there !

I have noticed something that could be linked to my past problem (see first message of this thread).

I have a script in the on_keypress function :

if (keycode==eKeyCtrlH) Display("Something");

The thing is that when I hit the "delete" key (the arrow pointing to the left on the keyboard, used to remove characters in a text), this function is called (I see the "Something" message).

Any ideas of why ?
Title: Re: Click outside the windowed mode problems
Post by: Khris on Wed 02/06/2021 13:00:26
Looks like AGS uses 1-26 for Ctrl+Letter, so Ctrl+A = 1, Ctrl+B = 2, CtrlH = 8, etc.

ASCII code 8 is indeed backspace, so they're the same keypress to AGS. This is listed in the manual btw, eKeyCtrlH == eKeyBackspace == 8.
Could be considered a bug actually.

Here's a workaround:

Code (ags) Select
  bool ctrl = IsKeyPressed(405) || IsKeyPressed(406);
 
  if (keycode == eKeyCtrlH && ctrl) Display("Something");
  if (keycode == eKeyBackspace && !ctrl) Display("Backspace");


(However, none of this is related to the weird "clicking outside the window issue" as far as I can tell)