Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewport emit mouse_enter/exit even when dragging Control #54565

Closed
wants to merge 1 commit into from

Conversation

jeremyz
Copy link
Contributor

@jeremyz jeremyz commented Nov 3, 2021

fixes #20881
linked to #54552

add a boolean property to the Viewport to allow it to send mouse_entered and mouse_exited signals even when dragging (mouse button clicked) from a Control.

Test Scene:

[gd_scene load_steps=2 format=3 uid="uid://deqgi4hacbarj"]

[sub_resource type="GDScript" id="1"]
script/source = "extends Node2D

func _ready():
	var _r
	_r = $ViewportContainer/Viewport/b1.connect(\"mouse_entered\", _entered, [\"b1\"])
	_r = $ViewportContainer/Viewport/b1.connect(\"mouse_exited\", _exited, [\"b1\"])
	_r = $ViewportContainer/Viewport/b2.connect(\"mouse_entered\", _entered,[\"b2\"])
	_r = $ViewportContainer/Viewport/b2.connect(\"mouse_exited\", _exited,[\"b2\"])
	_r = $ViewportContainer/Viewport/ck.connect(\"toggled\", _toggled)

func _entered(who):
	print(\"mouse area entered : %s\" % who)

func _exited(who):
	print(\"mouse area exited : %s\" % who)

func _toggled(v):
	$ViewportContainer/Viewport.gui_force_mouse_events = v
"

[node name="Node2D" type="Node2D"]
script = SubResource( "1" )

[node name="ViewportContainer" type="SubViewportContainer" parent="."]
script = null
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Viewport" type="SubViewport" parent="ViewportContainer"]
handle_input_locally = false
debug_draw = 3
size = Vector2i(800, 600)
render_target_update_mode = 4
script = null

[node name="b1" type="Button" parent="ViewportContainer/Viewport"]
offset_left = 150.0
offset_top = 100.0
rect_rotation = -23.2
focus_mode = 0
script = null
__meta__ = {
"_edit_use_anchors_": false
}

[node name="b2" type="Button" parent="ViewportContainer/Viewport"]
offset_left = 150.0
offset_top = 150.0
offset_right = 230.4604
offset_bottom = 380.158
rect_rotation = 38.7
rect_scale = Vector2(0.5, 0.5)
rect_pivot_offset = Vector2(1, 0)
focus_mode = 0
script = null
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ck" type="CheckBox" parent="ViewportContainer/Viewport"]
offset_right = 24.0
offset_bottom = 31.0
script = null
__meta__ = {
"_edit_use_anchors_": false
}

@akien-mga
Copy link
Member

Probably superseded by #67791. Could you check that PR to confirm?

@akien-mga akien-mga modified the milestones: 4.0, 4.1 Feb 12, 2023
@akien-mga
Copy link
Member

Probably superseded by #67791. Could you check that PR to confirm?

No answer, so closing for now as likely superseded by #67791.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"mouse_entered" and "mouse_exited" signals are broken while holding down a mouse button
3 participants