0 votes

Textedit has lots of properties, methods, styles and signals, but I've found no tutorial or documentation on what does what and how to use this control.

Since Godot uses it's own controls, I can see that Textedit is very powerful (I'm assuming it's the control used for the code editor). But how to use it? What does what?

I've found a video on Youtube ( https://youtu.be/nk0YQGb08IA ) about this but does not deal with any of the features that make it unique.

I've already asked for help at Reddit and I've got only one answer pointing me to the docs page (which does not explain anything, since it's an API reference - https://docs.godotengine.org/en/stable/classes/class_textedit.html) and to the source code of the control (which it's not useful since I don't know the engine's inner working).

I've done some experiments with various options but so far I've only got some keywords to get some color, but other words also appear with colors I haven't set.. Just "pushing all the buttons" hardly teaches me something useful.

Can somebody help?

in Engine by (104 points)

With all due respect, pushing all the buttons is a pretty good way to learn, at least in my experience, albeit in a time-consuming way. Learning is often frustrating and time-consuming. What about the documentation page is unclear? Your question is very broad. If you explained your goal and the impediments you're facing to achieve that goal, you might get more robust answers (I also find that writing down my goal and the specific problems sometimes makes the answer clearer, without needing input from others).

DDoop, thank you for taking the time to answer my question. For the last 6 months, I've been working with Godot everyday, fulltime and I've launched 2 games, make 3 prototypes and 2 tools. All this as been done thanks to "pushing all the buttons". But there must be a minimum documentation to start with because, if I don't know what's possible, I don't know what I can/want to do.

Textedit has lots of features. I would like to know how keywords work, how syntax highlight works, how code completion works, how selection, line folding and undo work. How to use breakpoints? What is automated and what must I code for these to work? If I have a keyword with a color, why do other words in my text get highlighted with other colors beside my defined keyword? Knowing the basics of the control allows for educated guessing and defining for what to (and not to) use.

Wanting to know what a thing does and the minimum of how it does it is always a broad question. Does anyone knows how to work with Textedit and provide a basic guidance?

1 Answer

+1 vote

The TextEdit control is clearly designed for in-editor code editing. The majority of the features you asked about are specific to this purpose. So unless you are using Godot to build a code editing tool, you are going to have to turn syntax highlighting off, accept that certain code highlighting is built-in, or dig into the C++ code to learn and modify the details.

Keywords are basic. You can set a string to have a certain color with a function call. Keywords are syntax highlighting, so that must be enabled.

The reason you are seeing other text highlighted when that is enabled is because it matches regular expressions for things like function names, variable assignment, etc.

Basically, unless you are building a GDScript editor, you should turn off syntax highlighting. If you are just looking for a way to put some text on the screen with highlighted words, using RichTextLabel with BBCode is a better approach.

https://docs.godotengine.org/en/stable/tutorials/gui/bbcode_in_richtextlabel.html

by (856 points)

Thank you for your answer Jim. I already use Richtextlabel on my projects.
So I should only try to understand how Textedit works if I know how Textedit works, otherwise I should not try to understand it - it's more or less what you're saying... And there is no information about this control anywhere, unless I'll learn how to develop the engine and make a sense out of the control's source code... This just seems so wrong...

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.