Character MLB atk called with GUI click MLB element: _gui_event, _unhandled_event, _input

Godot Version

4.3 (steam)

Question

Hello there! I need complete master help for next case:
We have 3 main event handlings:

  1. _gui_input
  2. _unhandled_input
  3. _input

Which accept events from some categories of input (as I may know):

  1. _gui_input accept event when mouse clicked on a gui item (event not continue handlings and not catched by _input/_unhandled)
  2. _unahndled_input accept event if some input called but not _gui_event & _input event not accept them
  3. _input accept ANY Input event as main handler

Ok, if Im wrong from steps above - please guide me! Thank you very Much!

Next:

My current architect for the game looks like:

image

In HUD I have main GUI for player/esc pressed (settings window) and etc…

The main screen scene is changed to game scenes (tilemaplayers, players, monsters, interactive_game_objects and etc…)

Video of trouble:

Problem description:
IF character NOT get any inputs in (_unhandled_input) mouse clicks on skill-panel - is work fine.
IF character GET any inputs parallel mouse clicks on skill-panel - he handle in _unhandled_input the character attack button
What I’ve expect: when player GET any inputs in _unhandled_input and mouse is interract with any GUI - character not handle MOUSE_INPUT at all.

The question is: why this happen? how you correctly setup your _unhandled_input/_input/_gui_input and how to fix my trouble? with examples if you can.

And please, sorry for my bad english!

Thank you very much for help!

P.S. code parts of Player with inputs (gui skill_panel doesnt have any overrided _unhandle_input/_gui_input etc…)

little part of main scene of all GUI - HUD:

P.S2:
I need help explaining how you set up your Input systems more than I need help with a piece of code. I read the Input documentation before coming here, but I don’t seem to understand it very well.

I’m not sure I understand everything you said (try translating to English with a translator tool next time maybe ?), but one thing that seems incorrect is the way your talk about “events not continuing to be handled”.

Priority is the following :

  1. _input
  2. _gui_input
  3. _unhandled_input

But if you want to STOP propagation of the event (meaning if you don’t want steps 2&3 to process input if it’s managed by step 1), you need to accept the event manually (it’s not automatic)

For this, you should use accept_event() (in Control nodes — the green ones) and get_viewport().set_input_as_handled() (in the other nodes)

I hope this helps you solving your issue!

1 Like

In general - it was me who turned out to be an idiot. But your words put me on the right path and I realized some things regarding the Input system.

I’m not 100% sure that this is was the problem (although everything worked) but: the input described inside _unhandled_input in the Player class for some reason ignored these accept_event and other things. But as soon as I added the following lines to the processing (checking the incoming event) everything suddenly worked and mouse clicks on the panel are now separated from mouse clicks of the player

image

and if you could help me with a wise explanation of why it worked, I would be a hundred times grateful to you!

(translated through a translator)

P.S. sorry for my bad eng. thanks!