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 property restricted_characters to Text/LineEdit #11646

Open
InkONat opened this issue Jan 26, 2025 · 1 comment
Open

Add property restricted_characters to Text/LineEdit #11646

InkONat opened this issue Jan 26, 2025 · 1 comment

Comments

@InkONat
Copy link

InkONat commented Jan 26, 2025

Describe the project you are working on

Level editor, but this goes for any project that needs the user input through Text/LineEdit to be more restricted

Describe the problem or limitation you are having in your project

Right now there is no property in the text editing control nodes that restricts the user from typing certain characters.

I need that because in my level editor you can add enemy pools that will determine what enemies can be spawned in the level using a TextEdit, and I want the user to not be able to type in the space character, since the pools are separated by "," (example "BIG_ENEMY,SMALL_ENEMY", but I can't do that currently - not without some more extra coding (see the workaround at the end of the issue)

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The restricted_characters property for Text/LineEdit would be able to easily restrict the user from typing the space character on my enemy pools TextEdit

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The restricted_characters would be a PackedStringArray, with each element being a character (if you were to add something more than one character to an element it would give a node warning and it just wouldn't count that element when restricting the characters). The user then wouldn't be able to add any of the characters in that list to the Text/LineEdit.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be worked around, as seen in this forum post https://forum.godotengine.org/t/how-to-make-a-restriction-on-the-characters-entered-on-lineedit/25965/2

but it's going to take some lines of code, so a simple property to stop that would be good to have.

Is there a reason why this should be core and not an add-on in the asset library?

Text/LineEdit are core

@AThousandShips
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants