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

Fix dragging in mesh preview will create a "drag and drop" action #83425

Conversation

jsjtxietian
Copy link
Contributor

@jsjtxietian jsjtxietian commented Oct 16, 2023

MaterialEditor doesn't have this problem. Did some check and found they have different parent class that caused the behaviour difference. So I change MeshEditor's parent from SubViewportContainer to Control. Tested locally, it worked.

I would appreciate any feedback or alternative suggestions.

Fixes #83171

Change MeshEditor's parent from SubViewportContainer to Control
@akien-mga
Copy link
Member

Why does changing the parent class specifically fix this issue?

The only functional difference I see is the added call to set_anchors_and_offsets_preset(PRESET_FULL_RECT);, which could be done while keeping the SubViewportContainer as the parent class.

It makes sense IMO to unify similar editors but I think in the past we've actually gone the other direction of trying to remove unnecessary intermediate nodes (CC @YeldhamDev).

@jsjtxietian
Copy link
Contributor Author

jsjtxietian commented Oct 16, 2023

First, thank you for your suggestions!

Why does changing the parent class specifically fix this issue?

I tested locally and find that set_anchors_and_offsets_preset(PRESET_FULL_RECT); won't fix this bug, it just affects some ui location.

To be honest I do not know how the drag and drop works but I suspect it may have something to do with subviewportcontainer's event propagation. And the material editor works well when inheriting Control, I tried and it worked. We definitely should investiagte more, someone know drag and drop well can help here.

Also, unify similar editors is one concern, another one is that it reduces the inheritance chain which could be beneficial.

@akien-mga
Copy link
Member

CC @Sauermann who might know why drag and drop behaves differently on Control and SubViewportContainer.

@Sauermann
Copy link
Contributor

For me this part of the editor is difficult to digest.
I found out, that the Control, node, that gets dragged, is a EditorPropertyResource.
This class inherits from EditorProperty, which has dragging enabled:

Variant EditorProperty::get_drag_data(const Point2 &p_point) {
if (property == StringName()) {
return Variant();
}
Dictionary dp;
dp["type"] = "obj_property";
dp["object"] = object;
dp["property"] = property;
dp["value"] = object->get(property);
Label *drag_label = memnew(Label);
drag_label->set_text(property);
set_drag_preview(drag_label);
return dp;
}

I have the feeling, that it is intentional, that dragging a EditorPropertyResource leads to a drag & drop operation. Although in this case it looks like it is not what is expected, because this EditorPropertyResource contains a SubViewport, where dragging should result in rotating the object.

Perhaps the EditorPropertyResource requires a way to tell it, if drag and drop should be used for dragging the resource or not.

Without knowing this part of the code-base, I have the feeling, that replacing the Node inheritance (SubViewportContainer -> Control) just hides the underlying problem. But please note that this is just a guess.

I have also tested, that #67531 (rebased on fd33c7b) also shows the same drag and drop behavior.

@KoBeWi
Copy link
Member

KoBeWi commented Jul 25, 2024

Looks like the issue is no longer reproducible.

@KoBeWi KoBeWi modified the milestones: 4.3, 4.4 Jul 25, 2024
@KoBeWi
Copy link
Member

KoBeWi commented Jul 25, 2024

Ok confirmed fixed by some another PR.
Thanks for the contribution nonetheless.

@KoBeWi KoBeWi closed this Jul 25, 2024
@KoBeWi KoBeWi removed this from the 4.4 milestone Jul 25, 2024
@jsjtxietian jsjtxietian deleted the prevent-drag-mesh-preview-create-drag-and-drop branch July 26, 2024 03:13
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.

Dragging in the Mesh Preview editor creates a "drag and drop" action.
5 participants