Godot: Why are LineEdit and TextEdit two separate nodes?

Created on 30 Jul 2018  Â·  7Comments  Â·  Source: godotengine/godot

Title says it all. I don't see why they can't be one node separated by a "Multi-line" option.

Many pieces of functionality I'd want to use are seemingly only covered by one of the two nodes, examples being:

  • Placeholder text (Only available in LineEdit)
  • Alignment (Only available in LineEdit)
  • Caret Block mode (Only in TextEdit)
  • Caret Moving by Right Click (Only in TextEdit)
  • Copying, cutting, and pasting text (Only in TextEdit via functions)
  • Undoing and redoing typing (Only in TextEdit via functions)

Some others have different names or methods of using them, which makes using the two nodes wildly different:

  • Readonly functionality is available in both, but it's called "Editable" in LineEdit
  • Caret Position is available in both, but where in LineEdit it's a simple int property (along with select() and select_all()), in TextEdit it's only possible to select text using the select() function, which has wildly different syntax than LineEdit's select().
  • LineEdit has the text_changed(String new_text) signal, where TextEdit has text_changed().

So I ask again, why are these two separate nodes? Why can't they be one node separated by a "multi-line" option, especially because much of their purpose overlaps, and so the use cases for the two might overlap as well. It seems like combining the two would ease developing for them as well -- when one gets functionality, the other should too, but currently that requires implementing the code twice.

archived

Most helpful comment

Yeah but much of the functionality I'd want from either is either overlapping but with different names, or just plain missing from one or the other. The inconsistencies between the two makes it harder to understand the other.

I want to use placeholder text for a Name field, but because I have a Description field that uses TextEdit, and I want to avoid having to change my code every time I add a new field alongside those two, I have to treat them as the same thing -- which in this case, I can't do, because their APIs are different from each other in a very wild manner. It means that if I want to use placeholder text, I have to use LineEdit. But then, if I want to cut, copy, and paste from code, I have to use TextEdit, which means getting rid of placeholder text.

At the least, don't dismiss this issue so fast. Please.

All 7 comments

Same reason why we have Tree and ItemList, Label and RichText or the many
buttons. Huge classes for simple things are messy and unintuitive.

On Mon, Jul 30, 2018, 16:15 LikeLakers2 notifications@github.com wrote:

Title says it all. I don't see why they can't be one node separated by a
"Multi-line" option.

Many pieces of functionality I'd want to use are seemingly only covered by
one of the two nodes, examples being:

  • Placeholder text (Only available in LineEdit)
  • Alignment (Only available in LineEdit)
  • Caret Block mode (Only in TextEdit)
  • Caret Moving by Right Click (Only in TextEdit)
  • Copying, cutting, and pasting text (Only in TextEdit via functions)
  • Undoing and redoing typing (Only in TextEdit via functions)

Some others have different names or methods of using them, which makes
using the two nodes wildly different:

  • Readonly functionality is available in both, but it's called
    "Editable" in LineEdit
  • Caret Position is available in both, but where in LineEdit it's a
    simple int property (along with select() and select_all()), in
    TextEdit it's only possible to select text using the select()
    function, which has wildly different syntax than LineEdit's select().
  • LineEdit has the text_changed(String new_text) signal, where
    TextEdit has text_changed().

So I ask again, why are these two separate nodes? Why can't they be one
node separated by a "multi-line" option, especially because much of their
purpose overlaps, and so the use cases for the two might overlap as well.
It seems like combining the two would ease developing for them as well --
when one gets functionality, the other should too, but currently that
requires implementing the code twice.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/20611, or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z21kEB94kh57XYBjEWszGOQ1wA2Opks5uL1tvgaJpZM4VnAnI
.

TextEdit, Tree and RichText are huge, with more complex APIs and setup a ton of parameters. you don't need to use or understand this complexity in most cases, specially when they are used a lot less often than their simple counterparts.

Yeah but much of the functionality I'd want from either is either overlapping but with different names, or just plain missing from one or the other. The inconsistencies between the two makes it harder to understand the other.

I want to use placeholder text for a Name field, but because I have a Description field that uses TextEdit, and I want to avoid having to change my code every time I add a new field alongside those two, I have to treat them as the same thing -- which in this case, I can't do, because their APIs are different from each other in a very wild manner. It means that if I want to use placeholder text, I have to use LineEdit. But then, if I want to cut, copy, and paste from code, I have to use TextEdit, which means getting rid of placeholder text.

At the least, don't dismiss this issue so fast. Please.

As an example, if I want to disable all text fields I have under a control, I have to do this if I want to allow adding more fields without editing the code every time:

for text_field in some_parent_node.get_children():
    if text_field is LineEdit:
        text_field.editable = false
    elif text_field is TextEdit:
        text_field.readonly = true
    else:
        # Something else...

This just looks and feels bad to type... it feels inconsistent. It feels like it wasn't thought out well. Why do I need to type false for one, and true for the other? Why are the names different? Why can't you have a consistent API between two nodes that are effectively the same bar one having multi-line editing?????

Agreed, API is inconsistent, there was an issue to track these problems and
fix them in future compat breaking releases.. but I am on the phone and
can't search. If anyone can do this, it's welcome (sync functions and
properties between LineEdit amd TextEdit)

On Mon, Jul 30, 2018, 17:03 LikeLakers2 notifications@github.com wrote:

As an example, if I want to disable all text fields I have in a control, I
have to do this if I want to allow adding more fields without editing the
code every time:

for text_field in some_parent_node.get_children():
if text_field is LineEdit:
text_field.editable = false
elif text_field is TextEdit:
text_field.readonly = true
else:
# Something else...

This just looks and feels bad to type... it feels inconsistent. It feels
like it wasn't thought out well. Why do I need to type false for one, and
true for the other? Why are the names different? Why can't you have a
consistent API between two nodes that are effectively the same bar one
having multi-line editing?????

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/20611#issuecomment-408991609,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z20NNmdT3iNGZXrYF68lC5OXW4krIks5uL2Z5gaJpZM4VnAnI
.

This is the issue for API breaking changes: #16863

@vnen Thanks. I'll put my suggestion in there.

@reduz It occurred to me earlier just how antagonistic I was being towards you over this, when admittedly the title I chose for the issue was sort of misleading. My apologies for that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bojidar-bg picture bojidar-bg  Â·  3Comments

testman42 picture testman42  Â·  3Comments

n-pigeon picture n-pigeon  Â·  3Comments

ducdetronquito picture ducdetronquito  Â·  3Comments

Zylann picture Zylann  Â·  3Comments