Open nosdregamon opened 1 year ago
Would it be better to use autocomplete in this case?
In most cases, I belive typing .pos<enter>
is more convenient than typing .
, searching for the property in the inspector and drag & drop.
One use case of quoted names is for accessing properties that don't have autocomplete available, e.g. properties that have slashes in their name.
I'm ready to make a pull request for this. However, I have some other ideas for what CTRL might do that I want to try out first. I might do a counter proposal, but first I want to experiment to see if my ideas are feasible.
Addendum 1: I have opened a counter-proposal: https://github.com/godotengine/godot-proposals/issues/8017 Addendum 2: I have made a pull request for this.
@timothyqiu : it's probably faster, if you know what you're searching for, but I'm starting from 0 again and often don't know, until I found it in the inspector. Perhaps think of it as an accessibility-feature for newbies ?
@theraot : that sounds even more more awesome. Thank you.
I'd ask the following question: when you don't want property to have quotation marks? Only cases I can think of are:
object.property
syntax.Both of these are easy to identify by checking the character before the dropping point, and leave quotes out if matching '
, "
or .
. This way the user doesn't need to press the modifier key for this.
@aXu-AP That sounds tempting, but I'm going to use an argument similar to yours.
# look I'm a comment and I end in a period.
, you get no quotes.obj.text = "my_incomplete_string
, you would get quotes.And sure, we could parse more of the code and figure it out (and that probably would be a bigger mess)… Would it not be more predictible if the generated code only depended on what you dragged and how, and not on where you drop it?
@theraot Hmm, good points. I think your counter proposal might be the best way to proceed.
it's probably faster, if you know what you're searching for, but I'm starting from 0 again and often don't know, until I found it in the inspector. Perhaps think of it as an accessibility-feature for newbies ?
I'm not sure if it's worth it to make a feature that is:
See my main comment: https://github.com/godotengine/godot-proposals/issues/8017#issuecomment-1751669874
@aXu-AP:
I'd ask the following question: when you don't want property to have quotation marks?
Perhaps I'm not programming the intended way, but so far I barely ever used them in quotation marks. For example, a function "dumbed down to work as an example" from a 2D experiment:
if position.distance_to(enemy.position)<20:
position = enemy.position
z_index = enemy.z_index
visible = true
#... and other code to end stealth mode and deal damage.
None of these properties work, if quoted.
@timothyqiu
Describe the project you are working on
I'm scripting in the Godot-Engine Editor for a 3rd Person RPG. The project however is pretty irrelevant, the idea can be applied whenever someone is scripting.
Describe the problem or limitation you are having in your project
I just noticed, that I can drag properties from the inspector into code. Just search for the the property I want, say Node2d->Position, drag the name and I got "position" in my script - that's awesome (and I feel silly for not trying that earlier).
However, this always ends up in quotation marks, so it's "position" not just position and in scripts I usually need the latter. So I remove the quotation marks by hand. Not a big deal, but it would be "nice to have" quality of live improvement, to drag without quotes.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Ideally it would be it's own modifier shortcut (say "CTRL+Drag&Drop" to get the desired result, or "ALT+Drag&Drop" if CTRL does something in this regard already, that I overlooked). But currently nothing in that direction exists.
Someone more savvy in the Godot sources pointed me to...
https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/editor/plugins/script_text_editor.cpp#L1917-L1927
... which boils down to: it's currently always quoting.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I think the addition would be minimal such as replacing 'const String text_to_drop = _quote_drop_data(String(d["property"]));' in the code above with
const String text_to_drop = drop_modifier_pressed ? String(d["property"]) : _quote_drop_data(String(d["property"]));
https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/editor/plugins/script_text_editor.cpp#L1921
If this enhancement will not be used often, can it be worked around with a few lines of script?
I don't think, that this can be done with a script, as this looks "hardcoded".
Is there a reason why this should be core and not an add-on in the asset library?
As above: I don't think, that this can be done with a script, as this looks "hardcoded". For that reason I think, an addon wouldn't be able to work around this.