Class ScyllaNameField
A text field for naming something that will become a file, holding the portable-filename rules so every rename surface applies the same ones.
Inheritance
Implements
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public sealed class ScyllaNameField : ScyllaValidatedTextField, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Remarks
The rules themselves live in StringUtil and are shared with runtime code; this adds only the editor behavior around them. Illegal characters are removed as they are typed, and the whole-name rules are checked on commit.
Two things the live filter deliberately does not do. Both look like bugs and are not, so neither should be "fixed" without reading this.
- It does not strip a trailing space. Doing so makes a space impossible to type in the middle of a name: it would vanish the instant it was entered, before the user could reach the character meant to follow it.
-
It does not reject a reserved device name such as
NUL. A user on their way to typingNULLpasses throughNUL, and a live rejection would stop them getting there.
Both are whole-name rules, so both are enforced on commit instead, where the value is final and rejecting it is meaningful.
Constructors
ScyllaNameField(string)
Initializes a name field.
Declaration
public ScyllaNameField(string label = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | Optional label shown before the input. |
Methods
AttachFilter(TextField)
Installs the live filename filter on a plain UnityEngine.UIElements.TextField.
Declaration
public static void AttachFilter(TextField field)
Parameters
| Type | Name | Description |
|---|---|---|
| TextField | field | The field to filter. Ignored when |
Remarks
For fields that cannot be a ScyllaNameField, such as one built by a
list view's cell factory or supplied by a Unity control. The filtered value is
pushed back with SetValueWithoutNotify, so the callback does not re-enter.
FilterInput(string)
Rewrites text as it is typed, before validation sees it.
Declaration
protected override string FilterInput(string raw)
Parameters
| Type | Name | Description |
|---|---|---|
| string | raw | The text as typed. |
Returns
| Type | Description |
|---|---|
| string | The text to keep in the field. |
Overrides
Remarks
The default returns the input untouched. A subclass overrides this to strip characters that can never be legal, which is friendlier than letting the user type something the field will refuse on commit.
A live filter must only remove what is unconditionally wrong. Rules about the shape of the whole value belong in the validator, because a value can be legitimately invalid while the user is midway through typing a valid one.
Normalize(string)
Puts a committed name into the exact form that will be written to disk: surrounding whitespace removed, then any trailing period or space dropped.
Declaration
public static string Normalize(string raw)
Parameters
| Type | Name | Description |
|---|---|---|
| string | raw | The value read from the field. May be |
Returns
| Type | Description |
|---|---|
| string | The normalized name, or an empty string when nothing usable remains. |
Remarks
Windows silently strips a trailing period or space from a filename, so a name ending in either is not the name that lands on disk. Repairing the value rather than rejecting the edit lets the user keep what they typed; the validator then vets the result.