1+ Class extends _widget
2+
3+ property toSearch:= ""
4+ property page : Integer
5+
6+ // === === === === === === === === === === === === === === === === === === === === === === === ===
7+ Class constructor ()
8+
9+ Super:C1705 ()
10+
11+ This:C1470 .defaultValues ()
12+ This:C1470 .page := 1 + Num:C11 (Is Windows:C1573) // +1
13+
14+ If (Structure file:C489= Structure file:C489 (* ))\
15+ && (Is macOS:C1572 && Shift down:C543)/* 🚧 FOR TESTING PURPOSES */
16+
17+ This:C1470 .page + = 1
18+
19+ End if
20+
21+ // === === === === === === === === === === === === === === === === === === === === === === === ===
22+ Function init ()
23+
24+ Super:C1706 .init ()
25+
26+ var $container := This:C1470 .getContainerValue ()
27+
28+ If ($container .type = Is text:K8:3)\
29+ | ($container .type = Is string var:K8:2)
30+
31+ Form:C1466 .toSearch := String:C10 ($container .value )
32+ This:C1470 .update ()
33+
34+ End if
35+
36+ // === === === === === === === === === === === === === === === === === === === === === === === ===
37+ Function defaultValues ($force : Boolean)
38+
39+ If (Not:C34 (This:C1470 .inited ) || $force)
40+
41+ var <>SearchPicker_SearchText := ""
42+
43+ var <>SearchPicker_PopupFunction : Text
44+
45+ var <>SearchPicker_Menu : Text
46+
47+ <>SearchPicker_PopupFunction := "Scope" // (or "Values")
48+
49+ RELEASE MENU:C978 (<> SearchPicker_Menu)
50+ <>SearchPicker_Menu := ""
51+
52+ var <>SearchPicker_DummyText : Text
53+ var <>SearchPicker_Target : Pointer
54+ <>SearchPicker_Target := - > <>SearchPicker_DummyText
55+
56+ This:C1470 .inited := True:C214
57+
58+ End if
59+
60+ // === === === === === === === === === === === === === === === === === === === === === === === ===
61+ Function handleEvents ($e : Object)
62+
63+ $e := $e || FORM Event:C1606
64+
65+ // MARK:Form Method
66+ If ($e .objectName = Null:C1517)
67+
68+ Case of
69+
70+ // ________________________________________________________________________________
71+ : ($e .code = On Load:K2:1)
72+
73+ FORM GOTO PAGE:C247 (This:C1470 .page ; * )
74+
75+ This:C1470 .init ()
76+
77+ // ________________________________________________________________________________
78+ : ($e .code = On Bound Variable Change:K2:52)
79+
80+ var $container := This:C1470 .getContainerValue ()
81+
82+ If ($container .type = Is text:K8:3)\
83+ | ($container .type = Is string var:K8:2)
84+
85+ Form:C1466 .toSearch := String:C10 ($container .value )
86+ This:C1470 .update ()
87+
88+ End if
89+
90+ // ________________________________________________________________________________
91+ : ($e .code = On Activate:K2:9)
92+
93+ This:C1470 .manageFocus ($e )
94+
95+ // ________________________________________________________________________________
96+ End case
97+
98+ return
99+
100+ End if
101+
102+ // MARK: Widget Methods
103+ Case of
104+
105+ // ______________________________________________________
106+ : ($e .code = On Activate:K2:9)\
107+ || ($e .code = On Deactivate:K2:10)
108+
109+ This:C1470 .manageFocus ($e )
110+
111+ // ______________________________________________________
112+ : ($e .objectName = "search@")
113+
114+ Case of
115+
116+ // ________________________________________________________________________________
117+ : ($e .code = On After Edit:K2:43)
118+
119+ This:C1470 .setContainerValue (Get edited text:C655; [Is text :K8:3; Is string var:K8:2])
120+ This:C1470 .update ()
121+
122+ // ________________________________________________________________________________
123+ : ($e .code = On Getting Focus:K2:7)
124+
125+ If (This:C1470 .enterable )
126+
127+ OBJECT SET RGB COLORS:C628 (* ; "BgndRing@" ; FORM Get color scheme:C1761= "dark" ? "silver" : "grey" ; Background color:K23:2 )
128+
129+ Else
130+
131+ OBJECT SET RGB COLORS:C628 (* ; "BgndRing@" ; FORM Get color scheme:C1761= "dark" ? "grey" : "silver" ; Background color:K23:2 )
132+
133+ End if
134+
135+ // ________________________________________________________________________________
136+ : ($e .code = On Losing Focus:K2:8)
137+
138+ OBJECT SET RGB COLORS:C628 (* ; "BgndRing@" ; FORM Get color scheme:C1761= "dark" ? "grey" : "silver" ; Background color:K23:2 )
139+
140+ // ________________________________________________________________________________
141+ End case
142+
143+ // ______________________________________________________
144+ : ($e .objectName = "close@")
145+
146+ Form:C1466 .toSearch := ""
147+ This:C1470 .setContainerValue ("" ; [Is text :K8:3; Is string var:K8:2])
148+ This:C1470 .update ()
149+
150+ // ______________________________________________________
151+ End case
152+
153+ // === === === === === === === === === === === === === === === === === === === === === === === ===
154+ Function update ()
155+
156+ var $container := This:C1470 .getContainerValue ()
157+
158+ If ($container .type = Is text:K8:3)\
159+ | ($container .type = Is string var:K8:2)
160+
161+ This:C1470 .setContainerValue (String:C10 ($container .value ); [Is text :K8:3; Is string var:K8:2])
162+
163+ End if
164+
165+ If (This:C1470 .page = 1)
166+
167+ OBJECT SET VISIBLE:C603 (* ; "CloseButton_Mac" ; Length:C16 ($container .value )> 0 )
168+
169+ Else
170+
171+ If (Length:C16 ($container .value )> 0)
172+
173+ OBJECT SET FORMAT:C236 (* ; "CloseButton_Win" ; ";file:Images/SearchBox/win_close.svg" )
174+
175+ Else
176+
177+ OBJECT SET FORMAT:C236 (* ; "CloseButton_Win" ; ";file:Images/SearchBox/win_glass.svg" )
178+
179+ End if
180+ End if
181+
182+ // === === === === === === === === === === === === === === === === === === === === === === === ===
183+ Function manageFocus ($e : Object)
184+
185+ $e := $e || FORM Event:C1606
186+
187+ If (This:C1470 .enterable )
188+
189+ If (This:C1470 .page = 1)
190+
191+ GOTO OBJECT:C206 (* ; "SearchText_Mac" )
192+
193+ Else
194+
195+ GOTO OBJECT:C206 (* ; "SearchText_Win" )
196+
197+ End if
198+
199+ Else
200+
201+ GOTO OBJECT:C206 (* ; "" )
202+
203+ End if
204+
205+ // <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
206+ Function set placeholder ($value : Text)
207+
208+ OBJECT SET PLACEHOLDER:C1295 (* ; This:C1470 .page = 1 ? "SearchText_Mac" : "SearchText_Win" ; $value )
209+
210+ // <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
211+ Function get enterable () : Boolean
212+
213+ return OBJECT Get enterable:C1067 (* ; This:C1470 .page = 1 ? "SearchText_Mac" : "SearchText_Win" )
214+
215+ // <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
216+ Function set enterable ($value : Boolean)
217+
218+ // This._enterable:=$value
219+
220+ If (This:C1470 .page = 1)
221+
222+ OBJECT SET ENTERABLE:C238 (* ; "SearchText_Mac" ; $value )
223+
224+ Else
225+
226+ OBJECT SET ENTERABLE:C238 (* ; "SearchText_Win" ; $value )
227+
228+ End if
229+
230+ This:C1470 .manageFocus ()
231+
232+ This:C1470 .update ()
233+
0 commit comments