Class ScyllaSearchField
A styled search text field with a clear button, an immediate
TextChanged event, and a debounced SearchChanged event.
Styled via the scylla-search USS class family.
Implements
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public sealed class ScyllaSearchField : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Remarks
Two change events are provided for different caller needs:
- TextChanged fires immediately on every keystroke. Use this for small data sets where instant per-keystroke filtering is cheap.
- SearchChanged fires after a DebounceDelayMs delay (default 200 ms). Use this for expensive filtering operations where running on every keystroke would cause noticeable lag.
The debounce is built on a single
DebouncedSafe(VisualElement, Action, long) entry created at construction
time and paused immediately. Each keystroke updates an internal
_pendingSearchValue field, then pauses and re-arms the entry via
ExecuteLater. This reuses one scheduler entry across every keystroke
and the entry pauses automatically on
UnityEngine.UIElements.DetachFromPanelEvent, so any pending callback after the host
panel tears down is suppressed.
The clear button (x label) is hidden while the field is empty and shown
as soon as the user types. Clicking it calls ClearSearch().
Constructors
ScyllaSearchField(string)
Creates a new search field with a placeholder.
Declaration
public ScyllaSearchField(string placeholder = "Search...")
Parameters
| Type | Name | Description |
|---|---|---|
| string | placeholder | Placeholder text shown when the field is empty. |
Properties
DebounceDelayMs
The delay in milliseconds between the last keystroke and the SearchChanged event. Adjusting this at runtime takes effect on the next keystroke. Default: 200 ms.
Declaration
public long DebounceDelayMs { get; set; }
Property Value
| Type | Description |
|---|---|
| long | The debounce delay in milliseconds. |
Value
The current text in the search field. Never null; returns
Empty when the field is empty.
Declaration
public string Value { get; }
Property Value
| Type | Description |
|---|---|
| string | The current search string. |
Methods
ClearSearch()
Clears the search field, hides the clear button, and fires both TextChanged and SearchChanged immediately with an empty string. Use this to reset the search state from code without user interaction.
Declaration
public void ClearSearch()
Events
SearchChanged
Fired after the search text changes (debounced). The argument is the new search text.
Declaration
public event Action<string> SearchChanged
Event Type
| Type | Description |
|---|---|
| Action<string> |
TextChanged
Fired immediately on every keystroke, bypassing the DebounceDelayMs delay used by SearchChanged. Use this for callers that need live filtering and don't mind the extra invocations (e.g. a small library list where re-filtering is cheap).
Declaration
public event Action<string> TextChanged
Event Type
| Type | Description |
|---|---|
| Action<string> |