-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.lua
More file actions
executable file
·713 lines (586 loc) · 22.8 KB
/
UI.lua
File metadata and controls
executable file
·713 lines (586 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
local addonName, ns = ...
local OUTER_WIDTH = 520
local OUTER_PADDING = 12
local SEARCH_HEIGHT = 48
local DROPDOWN_GAP = 8
local ROW_HEIGHT = 52
local ROW_SPACING = 2
local CONTENT_PADDING = 6
local FAVORITE_BUTTON_SIZE = 18
local FAVORITE_BUTTON_GAP = 12
local RIGHT_ROW_PADDING = 14
local TEXT_VERTICAL_OFFSET = -3
local SECURE_TYPE_SUFFIX = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE and "release" or ""
local function applyBackdrop(frame, bgR, bgG, bgB, bgA, borderR, borderG, borderB, borderA)
frame:SetBackdrop({
bgFile = "Interface/Buttons/WHITE8X8",
edgeFile = "Interface/Buttons/WHITE8X8",
edgeSize = 1,
})
frame:SetBackdropColor(bgR, bgG, bgB, bgA)
frame:SetBackdropBorderColor(borderR, borderG, borderB, borderA)
end
local function createText(parent, layer, fontObject, r, g, b)
local text = parent:CreateFontString(nil, layer, fontObject)
text:SetJustifyH("LEFT")
text:SetJustifyV("MIDDLE")
if r and g and b then
text:SetTextColor(r, g, b)
end
return text
end
local function getPlayerClassColor()
local classFilename = select(2, UnitClass("player"))
local classColors = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
local classColor = classFilename and classColors and classColors[classFilename]
if classColor then
return classColor.r, classColor.g, classColor.b
end
return 0.28, 0.56, 0.86
end
local function getSecureResultBinding(result)
if not result then
return nil
end
if result.macroText and result.macroText ~= "" then
return {
type = "macro",
macroText = result.macroText,
}
end
return nil
end
local function updateFavoriteButtonState(button, isSelected)
if not button.favoriteButton then
return
end
local atlas = button.isFavorite and "auctionhouse-icon-favorite" or "auctionhouse-icon-favorite-off"
button.favoriteButton.icon:SetAtlas(atlas)
local alpha
if button.isFavorite then
alpha = button.favoriteButton.isHovered and 1 or (isSelected and 0.95 or 0.80)
else
alpha = button.favoriteButton.isHovered and 0.75 or (isSelected and 0.50 or 0.28)
end
if button.isDisabled then
alpha = alpha * 0.75
end
button.favoriteButton.icon:SetAlpha(alpha)
end
local function setButtonState(button, isSelected)
if isSelected then
local r, g, b = getPlayerClassColor()
button:SetBackdropColor(r, g, b, 0.15)
button:SetBackdropBorderColor(r, g, b, 0.40)
if button.isDisabled then
button.title:SetTextColor(0.52, 0.56, 0.62)
button.subtitle:SetTextColor(0.43, 0.46, 0.50)
else
button.title:SetTextColor(0.96, 0.97, 0.99)
button.subtitle:SetTextColor(0.73, 0.77, 0.83)
end
else
button:SetBackdropColor(1.00, 1.00, 1.00, 0.00)
button:SetBackdropBorderColor(1.00, 1.00, 1.00, 0.00)
if button.isDisabled then
button.title:SetTextColor(0.42, 0.45, 0.50)
button.subtitle:SetTextColor(0.34, 0.37, 0.41)
else
button.title:SetTextColor(0.88, 0.89, 0.92)
button.subtitle:SetTextColor(0.57, 0.60, 0.66)
end
end
if button.icon.SetDesaturated then
button.icon:SetDesaturated(button.isDisabled)
end
button.icon:SetAlpha(button.isDisabled and 0.45 or 1)
updateFavoriteButtonState(button, isSelected)
end
local function getLineView(result)
local lineView = result.lineView or {}
local subtitle = lineView.subtitle
if subtitle == "" then
subtitle = nil
end
return {
icon = lineView.icon or result.icon or 134400,
title = lineView.title or result.title or "",
subtitle = subtitle,
disabled = lineView.disabled or false,
}
end
local function applyLineView(button, result)
local lineView = getLineView(result)
button.isDisabled = lineView.disabled
button.icon:SetTexture(lineView.icon)
button.title:SetText(lineView.title)
button.title:ClearAllPoints()
button.subtitle:ClearAllPoints()
if lineView.subtitle then
button.title:SetPoint("BOTTOMLEFT", button.textContainer, "LEFT", 0, 1 + TEXT_VERTICAL_OFFSET)
button.title:SetPoint("BOTTOMRIGHT", button.textContainer, "RIGHT", 0, 1 + TEXT_VERTICAL_OFFSET)
button.subtitle:SetPoint("TOPLEFT", button.textContainer, "LEFT", 0, -1 + TEXT_VERTICAL_OFFSET)
button.subtitle:SetPoint("TOPRIGHT", button.textContainer, "RIGHT", 0, -1 + TEXT_VERTICAL_OFFSET)
button.subtitle:SetText(lineView.subtitle)
button.subtitle:Show()
else
button.title:SetPoint("LEFT", button.textContainer, "LEFT", 0, TEXT_VERTICAL_OFFSET)
button.title:SetPoint("RIGHT", button.textContainer, "RIGHT", 0, TEXT_VERTICAL_OFFSET)
button.subtitle:SetText("")
button.subtitle:Hide()
end
end
function ns:CreateUI()
if self.ui then
return self.ui
end
local frame = CreateFrame("Frame", "SimpleSearchFrame", UIParent, "BackdropTemplate")
frame:SetSize(OUTER_WIDTH, OUTER_PADDING * 2 + SEARCH_HEIGHT)
frame:SetPoint("CENTER", 0, 90)
frame:SetFrameStrata("DIALOG")
frame:SetToplevel(true)
frame:SetClampedToScreen(true)
frame:Hide()
applyBackdrop(frame, 0.00, 0.00, 0.00, 0.80, 1.00, 1.00, 1.00, 0.08)
local glow = frame:CreateTexture(nil, "BACKGROUND")
glow:SetPoint("TOPLEFT", 1, -1)
glow:SetPoint("TOPRIGHT", -1, -1)
glow:SetHeight(56)
glow:SetColorTexture(0.22, 0.26, 0.34, 0.12)
local searchShell = CreateFrame("Frame", nil, frame, "BackdropTemplate")
searchShell:SetPoint("TOPLEFT", OUTER_PADDING, -OUTER_PADDING)
searchShell:SetPoint("TOPRIGHT", -OUTER_PADDING, -OUTER_PADDING)
searchShell:SetHeight(SEARCH_HEIGHT)
applyBackdrop(searchShell, 0.00, 0.00, 0.00, 0.40, 1.00, 1.00, 1.00, 0.04)
local searchBox = CreateFrame("EditBox", "$parentSearchBox", searchShell)
searchBox:SetHeight(34)
searchBox:SetAutoFocus(false)
searchBox:SetTextInsets(10, 10, 4, 4)
searchBox:SetFont(STANDARD_TEXT_FONT, 22, "")
searchBox:SetTextColor(0.95, 0.96, 0.98)
searchBox:SetJustifyH("LEFT")
searchBox:SetAltArrowKeyMode(false)
searchBox:SetMaxLetters(128)
local placeholder = createText(searchBox, "OVERLAY", "GameFontHighlightLarge", 0.46, 0.50, 0.56)
placeholder:SetPoint("LEFT", 18, 0)
placeholder:SetText("Search")
local prefixHint = createText(searchShell, "OVERLAY", "GameFontHighlightSmall", 0.38, 0.42, 0.48)
prefixHint:SetPoint("RIGHT", -18, 0)
prefixHint:SetText(ns:GetModulePrefixHint())
searchBox:SetPoint("LEFT", searchShell, "LEFT", 8, 0)
searchBox:SetPoint("RIGHT", prefixHint, "LEFT", -12, 0)
local resultsPane = CreateFrame("Frame", nil, frame)
resultsPane:SetPoint("TOPLEFT", searchShell, "BOTTOMLEFT", 0, -DROPDOWN_GAP)
resultsPane:SetPoint("TOPRIGHT", searchShell, "BOTTOMRIGHT", 0, -DROPDOWN_GAP)
resultsPane:SetHeight(0)
resultsPane:SetFrameStrata(frame:GetFrameStrata())
resultsPane:SetFrameLevel(searchShell:GetFrameLevel() + 1)
resultsPane:Hide()
local buttons = {}
local results = {}
local selectedIndex
local lastQueryKey = ""
local suppressInitialWhitespace = false
local isNormalizingSearchText = false
local executeButton = CreateFrame("Button", "SimpleSearchExecuteButton", frame, "InsecureActionButtonTemplate")
executeButton:RegisterForClicks("AnyDown", "AnyUp")
executeButton:SetAttribute("pressAndHoldAction", "1")
executeButton:SetAttribute("type", "macro")
executeButton:SetAttribute("macrotext", "")
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
executeButton:SetAttribute("typerelease", "macro")
end
executeButton:Hide()
local function getSelectedResult()
return results[selectedIndex or 1]
end
local function hasSelectedSecureBinding()
return getSecureResultBinding(getSelectedResult()) ~= nil
end
local function applyButtonSecureBinding(button, binding)
local typeAttribute = "type" .. SECURE_TYPE_SUFFIX .. "1"
button:SetAttribute("type1", nil)
button:SetAttribute("typerelease1", nil)
button:SetAttribute(typeAttribute, nil)
button:SetAttribute("macrotext", "")
if not binding then
return
end
if binding.type == "macro" then
button:SetAttribute(typeAttribute, "macro")
button:SetAttribute("macrotext", binding.macroText or "")
end
end
local function applyExecuteButtonSecureBinding(binding)
executeButton:SetAttribute("type", "macro")
executeButton:SetAttribute("macrotext", "")
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
executeButton:SetAttribute("typerelease", "macro")
end
if not binding then
return
end
if binding.type == "macro" then
executeButton:SetAttribute("type", "macro")
executeButton:SetAttribute("macrotext", binding.macroText or "")
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
executeButton:SetAttribute("typerelease", "macro")
end
end
end
local function updateSecureExecutionBinding()
ClearOverrideBindings(executeButton)
local binding = getSecureResultBinding(getSelectedResult())
applyExecuteButtonSecureBinding(binding)
if binding then
SetOverrideBindingClick(executeButton, true, "ENTER", executeButton:GetName())
SetOverrideBindingClick(executeButton, true, "NUMPADENTER", executeButton:GetName())
end
end
executeButton:HookScript("OnClick", function()
frame:HideSpotlight()
end)
local function findResultIndexByID(resultList, resultID)
if not resultID then
return nil
end
for index, result in ipairs(resultList) do
if result.id == resultID then
return index
end
end
return nil
end
local function updatePromptState()
local text = searchBox:GetText() or ""
local hasText = text:match("%S") ~= nil
prefixHint:SetText(ns:GetModulePrefixHint())
placeholder:SetShown(not hasText)
prefixHint:SetShown(not hasText and prefixHint:GetText() ~= "")
end
local function clearTransientSearchState()
selectedIndex = nil
lastQueryKey = ""
suppressInitialWhitespace = false
ns.currentQuery = ""
end
local function normalizeInitialWhitespace()
if isNormalizingSearchText or not suppressInitialWhitespace then
return false
end
local text = searchBox:GetText() or ""
if text == "" then
return false
end
suppressInitialWhitespace = false
local normalizedText = text:gsub("^%s+", "")
if normalizedText == text then
return false
end
isNormalizingSearchText = true
searchBox:SetText(normalizedText)
searchBox:SetCursorPosition(normalizedText:len())
isNormalizingSearchText = false
return true
end
local function setSearchShellHighlighted(isHighlighted)
if isHighlighted then
local r, g, b = getPlayerClassColor()
searchShell:SetBackdropBorderColor(r, g, b, 0.40)
else
searchShell:SetBackdropBorderColor(1.00, 1.00, 1.00, 0.04)
end
end
local function refreshButtonSelection()
for index, button in ipairs(buttons) do
setButtonState(button, button:IsShown() and index == selectedIndex)
end
end
local function setSelection(index)
if #results == 0 then
selectedIndex = nil
else
selectedIndex = math.max(1, math.min(index, #results))
end
refreshButtonSelection()
updateSecureExecutionBinding()
end
local function activateSelection()
local result = getSelectedResult()
if not result or getSecureResultBinding(result) or not result.action then
return
end
result.action(result)
end
local function handleEnterKey()
if ns:TryExecuteInput(searchBox:GetText() or "") then
return "handled"
end
if hasSelectedSecureBinding() then
return "propagate"
end
activateSelection()
return "handled"
end
local function doesBindingMatchKey(binding, key)
if not binding or binding == "" then
return false
end
local bindingKey = binding:match("([^%-]+)$")
if not bindingKey or bindingKey ~= key then
return false
end
local requiresAlt = binding:find("ALT%-", 1, true) ~= nil
local requiresCtrl = binding:find("CTRL%-", 1, true) ~= nil
local requiresShift = binding:find("SHIFT%-", 1, true) ~= nil
return requiresAlt == IsAltKeyDown()
and requiresCtrl == IsControlKeyDown()
and requiresShift == IsShiftKeyDown()
end
local function isToggleBindingPressed(key)
key = (key or ""):upper()
if key == "" or key == "ALT" or key == "CTRL" or key == "SHIFT" then
return false
end
local key1, key2 = GetBindingKey("SIMPLESEARCH_TOGGLE")
return doesBindingMatchKey(key1, key) or doesBindingMatchKey(key2, key)
end
for index = 1, ns.maxResults do
local button = CreateFrame("Button", nil, resultsPane, "InsecureActionButtonTemplate,BackdropTemplate")
button:SetPoint("TOPLEFT", resultsPane, "TOPLEFT", 0, -(CONTENT_PADDING + ((index - 1) * (ROW_HEIGHT + ROW_SPACING))))
button:SetPoint("TOPRIGHT", resultsPane, "TOPRIGHT", 0, -(CONTENT_PADDING + ((index - 1) * (ROW_HEIGHT + ROW_SPACING))))
button:SetHeight(ROW_HEIGHT)
button:SetFrameStrata(resultsPane:GetFrameStrata())
button:SetFrameLevel(resultsPane:GetFrameLevel() + 1)
button:RegisterForClicks("LeftButtonUp")
button:SetAttribute("pressAndHoldAction", "1")
applyButtonSecureBinding(button, nil)
applyBackdrop(button, 0.00, 0.00, 0.00, 0.00, 1.00, 1.00, 1.00, 0.00)
button.icon = button:CreateTexture(nil, "ARTWORK")
button.icon:SetSize(30, 30)
button.icon:SetPoint("LEFT", 12, 0)
button.favoriteButton = CreateFrame("Button", nil, button)
button.favoriteButton:SetSize(FAVORITE_BUTTON_SIZE, FAVORITE_BUTTON_SIZE)
button.favoriteButton:SetPoint("RIGHT", -RIGHT_ROW_PADDING, 0)
button.favoriteButton:RegisterForClicks("LeftButtonUp")
button.favoriteButton.icon = button.favoriteButton:CreateTexture(nil, "OVERLAY")
button.favoriteButton.icon:SetAllPoints()
button.textContainer = CreateFrame("Frame", nil, button)
button.textContainer:SetPoint("TOPLEFT", button, "TOPLEFT", 56, 0)
button.textContainer:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -(RIGHT_ROW_PADDING + FAVORITE_BUTTON_SIZE + FAVORITE_BUTTON_GAP), 0)
button.title = createText(button.textContainer, "OVERLAY", "GameFontNormal")
button.title:SetFont(STANDARD_TEXT_FONT, 18, "")
button.title:SetWordWrap(false)
button.subtitle = createText(button.textContainer, "OVERLAY", "GameFontHighlightSmall")
button.subtitle:SetFont(STANDARD_TEXT_FONT, 12, "")
button.subtitle:SetWordWrap(false)
button.resultIndex = index
button:SetScript("OnEnter", function(self)
setSelection(self.resultIndex)
end)
button:HookScript("OnClick", function(self)
setSelection(self.resultIndex)
local result = results[self.resultIndex]
if getSecureResultBinding(result) then
frame:HideSpotlight()
return
end
activateSelection()
end)
button.favoriteButton:SetScript("OnEnter", function(self)
local owner = self:GetParent()
self.isHovered = true
setSelection(owner.resultIndex)
updateFavoriteButtonState(owner, owner.resultIndex == selectedIndex)
local result = results[owner.resultIndex]
if result and result.id then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(ns:IsFavorite(result.id) and "Remove favorite" or "Add to favorites")
GameTooltip:Show()
end
end)
button.favoriteButton:SetScript("OnLeave", function(self)
self.isHovered = false
updateFavoriteButtonState(self:GetParent(), self:GetParent().resultIndex == selectedIndex)
GameTooltip:Hide()
end)
button.favoriteButton:SetScript("OnClick", function(self)
local owner = self:GetParent()
local result = results[owner.resultIndex]
if not result or not result.id then
return
end
setSelection(owner.resultIndex)
ns:ToggleFavorite(result.id)
searchBox:SetFocus()
end)
setButtonState(button, false)
button:Hide()
buttons[index] = button
end
local function getDropdownHeight(resultCount)
if resultCount <= 0 then
return 0
end
return CONTENT_PADDING * 2 + (resultCount * ROW_HEIGHT) + ((resultCount - 1) * ROW_SPACING)
end
function frame:UpdateLayout(resultCount)
local dropdownHeight = getDropdownHeight(resultCount)
if dropdownHeight > 0 then
resultsPane:SetHeight(dropdownHeight)
resultsPane:Show()
self:SetHeight((OUTER_PADDING * 2) + SEARCH_HEIGHT + DROPDOWN_GAP + dropdownHeight)
else
resultsPane:SetHeight(0)
resultsPane:Hide()
self:SetHeight((OUTER_PADDING * 2) + SEARCH_HEIGHT)
end
end
function frame:SetResults(newResults, prefixModule, query, showWithoutQuery)
local normalizedQuery = ns:NormalizeText(query)
local hasQuery = showWithoutQuery or prefixModule ~= nil or normalizedQuery ~= ""
local previousSelectedID = results[selectedIndex or 1] and results[selectedIndex or 1].id
local queryKey = (prefixModule and prefixModule.id or "") .. ":" .. normalizedQuery
results = hasQuery and (newResults or {}) or {}
if #results > 0 then
if queryKey == lastQueryKey then
selectedIndex = findResultIndexByID(results, previousSelectedID) or math.min(selectedIndex or 1, #results)
else
selectedIndex = 1
end
else
selectedIndex = nil
end
lastQueryKey = hasQuery and queryKey or ""
for index, button in ipairs(buttons) do
local result = results[index]
if result then
button.isFavorite = ns:IsFavorite(result.id)
applyLineView(button, result)
applyButtonSecureBinding(button, getSecureResultBinding(result))
button:Show()
else
button.isDisabled = false
button.isFavorite = false
applyButtonSecureBinding(button, nil)
button:Hide()
end
end
self:UpdateLayout(#results)
refreshButtonSelection()
updateSecureExecutionBinding()
end
function frame:RefreshResults()
local query = searchBox:GetText() or ""
ns.currentQuery = query
updatePromptState()
local searchResults, prefixModule, trimmedQuery, showWithoutQuery = ns:RunSearch(query)
self:SetResults(searchResults, prefixModule, trimmedQuery, showWithoutQuery)
end
function frame:MoveSelection(direction)
if #results == 0 then
return
end
setSelection((selectedIndex or 1) + direction)
end
function frame:HideSpotlight()
clearTransientSearchState()
self:Hide()
end
function frame:ShowSpotlight()
if not self:IsShown() then
searchBox:SetText("")
searchBox:SetCursorPosition(0)
suppressInitialWhitespace = true
updatePromptState()
end
self:Show()
searchBox:SetFocus()
searchBox:SetCursorPosition((searchBox:GetText() or ""):len())
self:RefreshResults()
end
function frame:Toggle()
if self:IsShown() then
self:HideSpotlight()
else
self:ShowSpotlight()
end
end
function frame:SetQuery(query)
query = query or ""
self:ShowSpotlight()
suppressInitialWhitespace = false
searchBox:SetText(query)
searchBox:SetCursorPosition(query:len())
end
searchShell:EnableMouse(true)
searchShell:SetScript("OnMouseDown", function()
searchBox:SetFocus()
end)
frame:SetScript("OnHide", function()
clearTransientSearchState()
ClearOverrideBindings(executeButton)
applyExecuteButtonSecureBinding(nil)
if searchBox.SetPropagateKeyboardInput then
searchBox:SetPropagateKeyboardInput(false)
end
searchBox:ClearFocus()
searchBox:SetText("")
updatePromptState()
frame:SetResults({}, nil, "", false)
end)
searchBox:SetScript("OnEscapePressed", function()
frame:HideSpotlight()
end)
searchBox:SetScript("OnEnterPressed", function()
if searchBox.SetPropagateKeyboardInput then
return
end
handleEnterKey()
end)
searchBox:SetScript("OnEditFocusGained", function()
setSearchShellHighlighted(true)
end)
searchBox:SetScript("OnEditFocusLost", function()
setSearchShellHighlighted(false)
end)
searchBox:SetScript("OnTextChanged", function()
if normalizeInitialWhitespace() then
return
end
frame:RefreshResults()
end)
searchBox:SetScript("OnKeyDown", function(self, key)
if isToggleBindingPressed(key) then
if self.SetPropagateKeyboardInput then
self:SetPropagateKeyboardInput(false)
end
return
end
if key == "ENTER" or key == "NUMPADENTER" then
local result = handleEnterKey()
if self.SetPropagateKeyboardInput then
self:SetPropagateKeyboardInput(result == "propagate")
end
return
end
if self.SetPropagateKeyboardInput then
self:SetPropagateKeyboardInput(false)
end
end)
searchBox:SetScript("OnArrowPressed", function(_, key)
if key == "UP" then
frame:MoveSelection(-1)
elseif key == "DOWN" then
frame:MoveSelection(1)
end
end)
updatePromptState()
setSearchShellHighlighted(false)
if searchBox.SetPropagateKeyboardInput then
searchBox:SetPropagateKeyboardInput(false)
end
table.insert(UISpecialFrames, frame:GetName())
self.ui = frame
return frame
end