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 property with CTRL/SHIFT generates code to get/set the property #82947

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theraot
Copy link
Contributor

@theraot theraot commented Oct 7, 2023

This pull request implements and closes: godotengine/godot-proposals#8017

Supercedes #82946

This pull request will allow Godot to:

  • Generate code to get value of a property dragged from the inspector while holding CTRL.
  • Generate code to set/assign a value of a property dragged from the inspector while holding SHIFT. The value being set will be the default value of the type of property, and it will be automatically selected in the code editor.
  • Generating code to access arrays and dictionaries is supported. But generating code for keys containing objects is not supported (this is a toast error). Similarly dropping the labels for a new item is not supported (this is a toast error).
  • Generating code to access metadata is supported.
  • Fixes dropping metadata generating text prefixed with "metadata/". Now the name of the metadata is dropped.
  • Fixes dropping dictionary keys or array indexes prefixes with "indices/". The key or index is dropped if possible, otherwise it is a toast error.
  • Bonus: dragging a property from project settings will drop the full property path (the code to get it or set it will not be generated).

@timothyqiu
Copy link
Member

One caveat is that node.property is not equvalent to node.get("property"). The former can act as setter too.

@theraot
Copy link
Contributor Author

theraot commented Oct 7, 2023

Yes. but:

  1. I rather not have a call to get if it is not necessary. Which also aligns this with QOL-Enhancement: Dragging properties from inspector into code without "Quotation marks" godot-proposals#8014 in the simple case.
  2. It didn't make sense to me to generate an assignment.

Addendum: I believe I could make an assignment/call to set with the current value of the property, but I think that would require to introduce another key modifier. Thus, I'm thinking that if people want that, it could be another proposal and pull request.

@aXu-AP
Copy link
Contributor

aXu-AP commented Oct 7, 2023

Seems to be working well 👍
If you manage to make subresources work, I hope shader parameters get some special attention, as those require the most writing/remembering. Could be a follow up though.
I think for set though, shift modifier could be used. In that case, caret should be moved to before closing bracket. And for the non-quotatable properties it should then add object.property = (of course, it's a bit extra, but it would be logical).

@theraot theraot force-pushed the betterpropertydraganddrop branch from c67b1df to 99cee38 Compare October 8, 2023 09:46
@theraot theraot changed the title Drag property with CTRL generates code to get the property Drag property with CTRL/SHIFT generates code to get/set the property Oct 8, 2023
@theraot theraot force-pushed the betterpropertydraganddrop branch 4 times, most recently from 858aa9a to dbd2bb7 Compare October 9, 2023 12:02
@theraot theraot force-pushed the betterpropertydraganddrop branch 2 times, most recently from 2cdac8d to 00f2fa1 Compare October 9, 2023 16:03
@theraot theraot force-pushed the betterpropertydraganddrop branch from 00f2fa1 to 9a2896a Compare October 9, 2023 16:09
@theraot theraot marked this pull request as ready for review October 9, 2023 23:58
@theraot theraot requested a review from a team as a code owner October 9, 2023 23:58
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 properties from inspector into code generates code to get the property
5 participants