I can't seem to limit the mouse click event to a single event.
I have tried numerous solutions posted for GODOT 3.5 and none have worked.
Has there been a change?

func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT:
			if event.is_pressed() && not event.is_echo():
				print("Left button was clicked at ", event.position)

Some examples on the net say to use is_just_pressed().
Where is the function is_just_pressed()? It doesn't seem to exist for event.

  • Your code works correctly (only single click event) for me in 4.0 beta 3. Which version of 4 are you using?
    Maybe the script with the _input is accidentally on multiple nodes?

    For the is_echo() part, the manual states: "Returns true if this input event is an echo event (only for events of type InputEventKey)."
    So its not for mouse events. Operating systems will repeat keyboard keys while they are held down, is_echo is for filtering those fake presses out. The OS doesn't do that with mice, so it isn't needed.

    Edit: also might be an OS thing. I'm on Win 10.

Thanks.
As far as I can tell is_action_just_pressed should not be used in the _input() loop.
I want to handle this in the _input function.
It is frustrating that is_echo doesn't seem to work with the mouse click.
Clearly I am missing something here.

    LeslieS I added a var to store last click tick stamp in ms, then check against a fixed value, to minic such function in key pressed event loop.

    Your code works correctly (only single click event) for me in 4.0 beta 3. Which version of 4 are you using?
    Maybe the script with the _input is accidentally on multiple nodes?

    For the is_echo() part, the manual states: "Returns true if this input event is an echo event (only for events of type InputEventKey)."
    So its not for mouse events. Operating systems will repeat keyboard keys while they are held down, is_echo is for filtering those fake presses out. The OS doesn't do that with mice, so it isn't needed.

    Edit: also might be an OS thing. I'm on Win 10.

      Edit:
      The calls to set_process_input(false) are ignored in the _input() function (as stated in the GODOT manual).
      Thanks for helping.

      Kojack
      Yes that seems to be what is happening.
      I have six instances of the node in the scene and there is exaclty six clicks processed.
      The thing is I shut off processing for all of them and only turn back on 1 of them.

      func _init():
      	print("DiceSprite._init()")
      	set_process(false)
      	set_process_input(false)
      ```   
      func activate_dice(): 
          	print("DiceSprite.activate_dice()")
              set_process_input(true)

      output:

      DiceSprite._init()
      DiceSprite._init()
      DiceSprite._init()
      DiceSprite._init()
      DiceSprite._init()
      DiceSprite._init()
      
      DiceSprite.activate_dice()
      
      xxxLeft button was clicked at (276, 144)
      xxxLeft button was clicked at (276, 144)
      xxxLeft button was clicked at (276, 144)
      xxxLeft button was clicked at (276, 144)
      xxxLeft button was clicked at (276, 144)
      xxxLeft button was clicked at (276, 144)