Input from mouse blocks mouse entered/exited signal functions

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MAJOR_KONTROL

BIG EDIT: I’m going to simplify my problem as much as possible.

I have one single Control node. It has a script and sends signals to itself that notify the script when mouse enters and exits nodes area.

func _process(delta):
	LeftClick = Input.is_mouse_button_pressed(BUTTON_LEFT)

	if mouse_over_control and LeftClick:
        print("both conditions are TRUE")

func _mouse_entered():
	mouse_over_control = true
	print("mouse entered")

func _mouse_exited():
	mouse_over_control = false
	print("mouse exited")

Problem is that as long as I provide mouse input (it works with keyboard keys!) functions that check if mouse is over control area don’t work. Because of that both conditions remain TRUE and the IF loop keeps running even when I move my mouse aside.

Tested in Godot 3 and Godot 2.1.4


I have two functions that notify me when mouse enters and exits a control node. Both send signals to a script that is attached to scenes root.

func _process(delta):
	LeftClick = Input.is_mouse_button_pressed(BUTTON_LEFT)

	if mouse_over_scroll_handle and LeftClick:
        do something

func _on_scroll_bar_handle_mouse_entered():
	mouse_over_scroll_handle = true
	print("mouse entered")

func _on_scroll_bar_handle_mouse_exited():
	mouse_over_scroll_handle = false
	print("mouse exited")

When I hold down LeftClick it prevents mouse enter/exit functions from working therefore condition “mouse_over_scroll” remains TRUE after inital “mouse entered” signal. It does work when I replace mouse with keyboard.

I have 2 theories so far:

  1. Checking for mouse button press overrides checking for mouse entering/exiting a control node area therefore it maybe working as intended.
  2. Bug.

I am getting the intended behavior in version 3.0 stable. I used both a control node and a horizontal scroll bar node. Is my usage replicated what you are trying to achieve?

2D||!2D | 2018-03-05 14:30

edit: I just simplified my question. It’s all you need to know.

I don’t have access to any image sharing site so my tree looks basically like this:

->control (scene root, script, receives signals)
----->control (emits mouse enter/exit signals, treat it as a button)

I’m creating a custom scrollbar. Mouse keeps moving the control even when it’s off the control node area (one condition is FALSE)

Additionally I recreated it in Godot 2.1.4. Same problem.

Thank you for your time.

MAJOR_KONTROL | 2018-03-05 15:21

Tested your code. I don’t think you’re getting intended results. Are you sure you’re getting “mouse out” when leaving Control node rect area, not when releasing mouse button?

MAJOR_KONTROL | 2018-03-06 00:14

I am pretty sure. I’ll try it in your version in the morning.

2D||!2D | 2018-03-06 03:13

I tested on v2.1.4 and it works as it should. LMB was held the entire time after scene was started. The only way I could get it to produce the behavior you are seeing is that if I set the mouse exit signal to one shot. I put the project at the link below. See if you are still having issues when using that project.


2D||!2D | 2018-03-06 12:29

I almost want to say that the problem is on my end but it occurs ONLY when I click inside the control and then drag the mouse outside of it. I’m not sure if that’s what you’ve been doing but if what I described here doesn’t occur for you then I’ll look for other reasons.

I’ve tested your project on two different PCs. Keeps happening.

MAJOR_KONTROL | 2018-03-06 13:16

Ahh…yes! I replicated your issue! You are not crazy! haha

Sorry, when I read “but it occurs ONLY when I click inside the control and then drag the mouse outside of it.” it clicked what the case was.

2D||!2D | 2018-03-06 14:09

There is a similar post here. Maybe this is a consequence of drag and drop?

2D||!2D | 2018-03-06 14:31