is it possible to detect if a keyboard input is coming from a user interface?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wombatTurkey
:warning: Old Version Published before Godot 3 was released.

Here is my issue:

And here is my input code:

func _input(event):
	if event.is_action_pressed("open_inventory"):
		get_tree().set_input_as_handled()
		OpenInventory()

open_inventory is tagged back to the letter i. Any idea on how I can check the event type of the input to see if it’s coming from a ui control? For example, in JavaScript / DOM we can check the target, see if its a input field, etc. Thanks!

(Not an answer since it is a workaround), but why not put a script on the input field, and make the input as handled there?

Bojidar Marinov | 2016-05-18 08:23

Well if I do that, then they have to be editing something to open up an inventory. I want to beable to open up the inventory whenever they are not editing something or in a ui widget (if that makes sense) – hard to explain

wombatTurkey | 2016-05-18 08:55

Have you tried _unhandled_input(event)?
Also, on which node did you placed the script? Maybe this could help http://docs.godotengine.org/en/latest/tutorials/engine/inputevent.html

Zylann | 2016-05-18 20:35