TextEdit: How to? Looking for a tutorial

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cgeadas

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 - TextEdit — Godot Engine (stable) documentation in English) 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?

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 | 2020-07-09 22:00

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?

cgeadas | 2020-07-09 22:21

:bust_in_silhouette: Reply From: JimArtificer

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.

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…

cgeadas | 2020-07-10 05:01

It’s like StackOverflow all over again, you’ve completely missed the point of their question, and on top of it don’t know what you’re talking about.

TextEdit node is not for ineditor code editing, it /cannot/ be used ‘in-editor’ at all.
It is there for implementing text editors in games/programs, but indeed there is very little documentation on some of the more program-oriented nodes like TextEdit and GraphEdit. Which is how I also ended up here.

AI | 2021-10-19 23:24

I am sorry that you are frustrated. It sounds like you aren’t aware that Godot’s editor was built with Godot. This additional information may help you understand my post above.

JimArtificer | 2021-11-29 02:27

I think what many are looking for, myself included, is a control that can be embedded in a game that allows players to enter something more than simple text and without having to look-up the [bbcodes] supported by the RichTextLabel control. In other words, we are looking for a control to do the same thing as the editor I’m using to type this comment.

If you take time to search this topic you’ll see many complex and bazar attempts to implement something in GDScript. None of the results are very good.

If Godot had a webview style control then any of the 100’s of Javascript editors could be used. However, is it unlikely (and undesirable) for Godot to ever have a webview control.

So, we are left wanting a control that allows game users to do something as simple as enter Rich Text without manually entering [BBcodes]. TextEdit appears to be the closest thing GDScript has available today. All that’s needed is some detailed documentation and the community will take it from there.

tx350z | 2022-01-21 15:21

:bust_in_silhouette: Reply From: SevenEater

The same creator, Emilio, has come out with some other useful tutorials on TextEdit’s. One that I found useful: