5 protected bool m_bColorizeText;
8 protected ref Color m_cDefault;
11 protected ref Color m_cFocused;
14 protected ref Color m_cSearched;
17 protected string m_sMessage;
19 [
Attribute(
"1",
desc:
"Should the message be hidden if there's text in the search bar")]
20 protected bool m_bHideMessageOnSearch;
22 protected ref array<Widget> m_aColorizedElements = {};
23 protected SCR_ESearchBoxState m_eState;
24 protected bool m_bIsFilterActive;
26 protected RichTextWidget m_wMessage;
27 protected SCR_ModularButtonComponent m_MessageButton;
28 protected string m_sLastSearch;
31 override protected void HandlerAttached(Widget w)
33 super.HandlerAttached(w);
40 m_aColorizedElements.Insert(m_wImgWriteIcon);
42 if (m_bColorizeText && m_wEditBoxWidget)
43 m_aColorizedElements.Insert(m_wEditBoxWidget);
46 Widget messageButton =
m_wRoot.FindAnyWidget(
"EditBoxMessageButton");
48 m_MessageButton = SCR_ModularButtonComponent.FindComponent(messageButton);
51 m_MessageButton.m_OnClicked.Insert(OnInternalButtonClicked);
53 SetMessage(m_sMessage);
55 m_wBorder.SetVisible(!m_bColorizeText);
61 override bool OnMouseEnter(Widget w,
int x,
int y)
67 return super.OnMouseEnter(w, x, y);
71 override void OnHandlerFocus()
73 super.OnHandlerFocus();
75 m_eState = SCR_ESearchBoxState.FOCUSED;
80 override void OnHandlerFocusLost()
84 OnConfirm(m_wEditBox);
86 super.OnHandlerFocusLost();
88 if (m_bIsFilterActive)
89 m_eState = SCR_ESearchBoxState.SEARCHED;
91 m_eState = SCR_ESearchBoxState.DEFAULT;
97 override protected void OnConfirm(Widget w)
102 m_bIsFilterActive =
GetValue() !=
string.Empty;
107 override void UpdateInteractionState(
bool forceDisabled)
109 super.UpdateInteractionState(forceDisabled);
114 bool hideMessage = m_bHideMessageOnSearch && (m_bIsInWriteMode || !GetEditBoxText().IsEmpty());
120 protected void UpdateWidgets(
bool animate =
true)
126 case SCR_ESearchBoxState.FOCUSED:
130 case SCR_ESearchBoxState.SEARCHED:
139 foreach (Widget element : m_aColorizedElements)
142 AnimateWidget.Color(element, color, m_fColorsAnimationTime);
144 element.SetColor(color);
149 bool SetMessage(
string message)
154 m_MessageButton.SetVisible(!message.IsEmpty());
156 if (!message.IsEmpty())
175 enum SCR_ESearchBoxState