Enum giving me a headache

Godot Version

4.5

Question

I thought ENUMS for controls were assigned by the engine core?

I have this error popping up.

Cannot assign 3 as Enum "TextServer.AutowrapMode": no enum member has matching value.

I used 3 in place of the enum from the docs since it wouldn’t recognize the variable name.

rich_text.autowrap_mode = 3

As per the docs:

AutowrapMode autowrap_mode = 3 

void set_autowrap_mode(value: AutowrapMode)

AutowrapMode get_autowrap_mode()

This is what I want: But the error says : Identifier “AutowrapMode” not declared in the current scope.gdscript(-1)

	rich_text.autowrap_mode = AutowrapMode.AUTOWRAP_WORD_SMART

Is there a way to fix this? I’m creating the richtext box in code but my module has Extends Node3d

RichTextBox inherits from Control. Attaching it to a Node3D is probably you problem.

1 Like

No, that wouldn’t break anything, I use it all the time. As long as you understand the shortcomings of this solution, it’s usually not a big deal.

As you can see in the docs, the AutorwapMode enum is part of the TextServer class.


Therefore you need to write it like that:

	rich_text.autowrap_mode = TextServer.AutowrapMode.AUTOWRAP_WORD_SMART
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.