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

Drag previews clipped by Popup that created them #67186

Open
rokiyo opened this issue Oct 10, 2022 · 1 comment
Open

Drag previews clipped by Popup that created them #67186

rokiyo opened this issue Oct 10, 2022 · 1 comment

Comments

@rokiyo
Copy link

rokiyo commented Oct 10, 2022

Godot version

4.0.beta2

System information

Windows 10

Issue description

Calling set_drag_preview() from a Control nested within an embedded PopupPanel will cause the preview to be clipped by that PopupPanel.

drag_clip

Seems possible that #64949 might fix this by allowing us to set the parent to the main viewport, but I don't understand the issue well enough to be sure about that.

Steps to reproduce

Some Controls nested within a PopupPanel:
image

The GridContainer in the image above has a script that instantiates each inventory slot as a scene, which looks like this:
image

The InventorySlotControl's script contains the following code:

func _get_drag_data(_position: Vector2):
	if item_stack is ItemStack:
		drag_data = { "item_stack": item_stack, "previous_slot": self }
		set_drag_preview(stack_container.duplicate())
		stack_taken.emit(get_index())
		return drag_data

func _can_drop_data(_position: Vector2, data) -> bool:
	return data is Dictionary and data.has("item_stack")

func _drop_data(_position: Vector2, data) -> void:
	stack_received.emit(get_index(), data)
	data.previous_slot.drag_data = null

func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_released("ui_left_mouse") and drag_data is Dictionary:
		accept_event()
		stack_received.emit(get_index(), drag_data)
		drag_data = null

Minimal reproduction project

No response

@rokiyo
Copy link
Author

rokiyo commented Oct 10, 2022

I also saw this mentioned by another user on the Godot Discord the other day:
image

They seemed to eventually uncover this as a potential root cause:
image

p_base->get_root_parent_control()->add_child(p_control); // Add as child of viewport.

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

No branches or pull requests

3 participants