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

Add Placeholder to TextEdit #57100

Merged
merged 1 commit into from
Jan 24, 2022
Merged

Conversation

Paulb23
Copy link
Member

@Paulb23 Paulb23 commented Jan 23, 2022

Adds a placeholder to TextEdit following the same naming scheme in LineEdit. Supports wrapping, newlines and scrolling.

Uses the same draw loop thanks to the TextServer abstractions, though does not appear on the minimap.

closes godotengine/godot-proposals/issues/1995

@Paulb23 Paulb23 added this to the 4.0 milestone Jan 23, 2022
@Paulb23 Paulb23 requested review from a team as code owners January 23, 2022 20:23
@@ -867,11 +873,14 @@ void TextEdit::_notification(int p_what) {

// Ensure we at least use the font color.
Color current_color = !editable ? font_readonly_color : font_color;
if (draw_placeholder) {
current_color.a *= placeholder_alpha;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to provide it as a dedicated theme color property (that can default to have 0.6 alpha).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same is used in the LineEdit, so if it's moved to the theme, it should be done for both.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do that as a follow-up PR for LineEdit and now TextEdit too.

@@ -867,11 +873,14 @@ void TextEdit::_notification(int p_what) {

// Ensure we at least use the font color.
Color current_color = !editable ? font_readonly_color : font_color;
if (draw_placeholder) {
current_color.a *= placeholder_alpha;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same is used in the LineEdit, so if it's moved to the theme, it should be done for both.

@akien-mga akien-mga merged commit 06abfd8 into godotengine:master Jan 24, 2022
@akien-mga
Copy link
Member

Thanks!

@Paulb23 Paulb23 deleted the textedit-placeholder branch January 24, 2022 19:32
@bend-n
Copy link
Contributor

bend-n commented Jun 4, 2022

Is this backported?

@Calinou
Copy link
Member

Calinou commented Jun 5, 2022

Is this backported?

No, it needs to be redone from scratch in 3.x as the TextEdit implementation is entirely different there.

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.

Add a placeholder property to TextEdit (like LineEdit already has)
6 participants