DayZ 1.24
Loading...
Searching...
No Matches
OptionSelectorEditbox.c
Go to the documentation of this file.
1class OptionSelectorEditbox extends OptionSelectorBase
2{
4
6 {
7 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/option_editbox.layout", parent);
8#ifdef PLATFORM_CONSOLE
9 m_Parent = parent.GetParent().GetParent();
10#else
11#ifdef PLATFORM_WINDOWS
12 m_Parent = parent.GetParent();
13#endif
14#endif
15
16 m_SelectorType = 1;
17 m_ParentClass = parent_menu;
18 m_EditBox = EditBoxWidget.Cast(m_Root.FindAnyWidget("option_value"));
19
21 Enable();
22
23 m_Parent.SetHandler(this);
24 }
25
27 {
28 delete m_Root;
29 }
30
31 override void Enable()
32 {
33 super.Enable();
34
35 m_EditBox.ClearFlags(WidgetFlags.IGNOREPOINTER);
36 }
37
38 override void Disable()
39 {
40 super.Disable();
41
42 m_EditBox.SetFlags(WidgetFlags.IGNOREPOINTER);
43 }
44
45 override bool OnMouseEnter(Widget w, int x, int y)
46 {
47 if (!IsFocusable(w))
48 return true;
49
50 if (m_ParentClass)
51 {
52 m_ParentClass.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
53 m_ParentClass.OnMouseEnter(m_Root.GetParent().GetParent(), x, y);
54 }
55
56 UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
57
58 if (menu && menu.IsInherited(CharacterCreationMenu))
59 {
60 menu.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
61 menu.OnMouseEnter(m_Root.GetParent().GetParent(), x, y);
62 }
63
65
66 return true;
67 }
68
69 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
70 {
72 return true;
73
74 if (m_ParentClass)
75 {
76 m_ParentClass.OnFocus(null, x, y);
77 m_ParentClass.OnMouseLeave(m_Root.GetParent().GetParent(), enterW, x, y);
78 }
79
80 UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
81
82 if (menu && menu.IsInherited(CharacterCreationMenu))
83 {
84 menu.OnFocus(null, x, y);
85 menu.OnMouseLeave(m_Root.GetParent().GetParent(), enterW, x, y);
86 }
87
89
90 return true;
91 }
92
93 override bool OnChange(Widget w, int x, int y, bool finished)
94 {
95 if (w == m_EditBox)
96 {
97 m_OptionChanged.Invoke(GetValue());
98 return true;
99 }
100 return false;
101 }
102
103 override bool IsFocusable(Widget w)
104 {
105 if (w)
106 return (w == m_Parent || w == m_EditBox);
107 return false;
108 }
109
110 override bool OnFocus(Widget w, int x, int y)
111 {
112 if (GetFocus() != m_EditBox)
113 {
114 SetFocus(m_EditBox);
115 m_Parent.Enable(false);
116 }
117
118 return super.OnFocus(m_Parent, x, y);
119 }
120
121 override bool OnFocusLost(Widget w, int x, int y)
122 {
123 if (w == m_EditBox)
124 {
125 m_Parent.Enable(true);
126 return super.OnFocusLost(m_Parent, x, y);
127 }
128 return false;
129 }
130
131 void SetValue(string value, bool update = true)
132 {
133 m_EditBox.SetText(value);
134 if (update)
135 m_OptionChanged.Invoke(GetValue());
136 }
137
138 string GetValue()
139 {
140 return m_EditBox.GetText();
141 }
142
143 override void ColorHighlight(Widget w)
144 {
145 if (!w)
146 return;
147
148 if (m_EditBox)
149 {
150 SetFocus(m_EditBox);
151 m_EditBox.SetColor(ARGB(255, 200, 0, 0));
152 }
153
154 super.ColorHighlight(w);
155 }
156
157 override void ColorNormal(Widget w)
158 {
159 if (!w)
160 return;
161
162 if (m_EditBox)
163 m_EditBox.SetColor(ARGB(140, 255, 255, 255));
164
165 super.ColorNormal(w);
166 }
167}
Icon x
Icon y
Widget m_Root
Definition SizeToChild.c:85
Widget m_Parent
Definition SizeToChild.c:86
override bool OnFocus(Widget w, int x, int y)
override bool OnChange(Widget w, int x, int y, bool finished)
override bool IsFocusable(Widget w)
override bool OnFocusLost(Widget w, int x, int y)
override void ColorHighlight(Widget w)
void OptionSelectorEditbox(Widget parent, string value, ScriptedWidgetEventHandler parent_menu, bool disabled)
override bool OnMouseEnter(Widget w, int x, int y)
override void Enable()
override void ColorNormal(Widget w)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void SetValue(string value, bool update=true)
map: item x vector(index, width, height)
Definition EnWidgets.c:651
proto native CGame GetGame()
WidgetFlags
Definition EnWidgets.c:58
proto native Widget GetFocus()
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322