• Godot HelpGUI
  • InputEventMouseButton + InputEventMouseMotion - Mouse Click Up Not Registering

So I posted this a few months ago https://godotforums.org/discussion/27785/help-with-panel-node-type-and-input-issues/p1

and got no help, so I just got rid of the panel indicator idea and continued on without that feature.

However, I've rebuilt my (card/image) carousel to change a few features and I've run into the same problem again, but in a different way.

I'm experiencing intermittent misses of the left mouse button up, resulting in the carousel sticking to the 'dragging' state when it should be released.

Sometimes it sticks no matter what I do for several clicks, sometimes if I just click once it 'unsticks,' sometimes it sticks, unsticks after I click, and then I can't get ANY input to register for several tries(either clicks or click ups). It's really busting up the whole thing.

here is the logic for the input:

func _gui_input(event):
  if event is InputEventMouseButton && event.button_index == BUTTON_LEFT:
    if event.button_index == BUTTON_LEFT && event.pressed:
      pressed = true
      click_down_position = event.global_position
      animation_state = "inactive"
      carousel_inertia_initial = 0
    elif event.button_index == BUTTON_LEFT && !event.pressed:
      click_up_position = event.global_position
      pressed = false
      animation_end_position = stepify(carousel_position, card_zone) + stepify(carousel_inertia_initial*20.0*1.8939,card_zone)
      animation_end_position = clamp(animation_end_position, 0, (last_card_in_carousel * card_zone))
      animation_state = "released"
   if event is InputEventMouseMotion:
      if pressed == true:
        animation_state = "dragging"
        carousel_position += event.relative.x
        carousel_position = clamp(carousel_position, 0, (last_card_in_carousel * card_zone))
        _carousel_card_position_manager(carousel_position)
        carousel_inertia_initial = event.relative.x
      elif pressed == false:
        pass

which includes the logic where the carousel position is clamped to the endpoints.

The purpose of that was to make it so when you are dragging the carousel beyond it's beginning or end limits, that the carousel stops moving.

There's also this little bit for adding inertia after the user drags the carousel and releases with sufficient momentum:

func _process(delta):
	if animation_state == "released":
		carousel_position = lerp(carousel_position, animation_end_position, 4.0*delta)
		_carousel_card_position_manager(carousel_position)
		if abs(animation_end_position - carousel_position) < 0.001:
			animation_state = "inactive"

This input issue ONLY happens when the carousel is at either endpoint, when I am dragging past the end. It would seem to me then that this must be related to clamping values, but I tested console printouts and the input event just isn't registering through _input(event). Where is the input going to then? Is there another method of clamping that might solve this?

This is a really important component of the app I've been building for a while now, so please, any suggestions are welcome, I am desperate to solve this issue.

If you drag off of the object, then the mouse up event won't fire and it will be stuck. You probably want to add an addition global mouse event (like on _input(event)) just to trigger the mouse up logic.

I could provide video but I don't know that it would explain well either.

It is a carousel of 'cards' as if you are scrolling horizonatally through a finite number of cards. At runtime, all you'll see at start is a window with one full card in the center and a small portion of another card to the right(cut off on the right side by the window). If you drag from right side to left, the carousel spins, and when you reach the other end of the carousel, there will be no card on the right side.

There is no card on the left when the carousel position is at the start. I have clamped the values of the carousel_position (as seen in the code I shared), so that if I were to drag the carousel to the right (clicking center card and dragging to the right) when I am at the beginning of the 'deck', the carousel does not move.

However, the cursor does not move off of the object during this process, so it is not a factor.

I will not ignore a possible solution though, so I will still try seeing if _input(event) click up logic provides me with any more information or a possible solution.

Yeah, it's hard to say without seeing the project. If you can make a minimum reproduction project I can take a look (like remove your artwork, or just copy out the relevant scene).

No worries, I moved the button_left && !event.is_pressed logic to _input(event), and it stopped doing it. I don't know how an input event could behave like that when I'm not dragging the cursor outside the container boundaries, but I won't complain about having a solution -- haha, thank you!

a year later