@@ -160,9 +160,11 @@ function addon:CreateOptionsV2Window()
160160 reloadButton :SetSize (76 , 22 )
161161 reloadButton :SetText (" ReloadUI" )
162162 reloadButton :SetScript (" OnClick" , function ()
163- if addon .PromptReloadUI then
163+ if addon .SafeReload then
164+ addon :SafeReload ()
165+ elseif addon .PromptReloadUI then
164166 addon :PromptReloadUI (" Reload UI now?" )
165- elseif ReloadUI then
167+ else
166168 ReloadUI ()
167169 end
168170 end )
@@ -420,6 +422,82 @@ function addon:CreateOptionsV2Window()
420422 end
421423 end
422424 frame :SetPage (target .key )
425+ if C_Timer and C_Timer .After then
426+ C_Timer .After (0.1 , function ()
427+ local currentStyle = addon :GetOptionsV2Style () or {}
428+ -- Silent: Check if section frames are available
429+ if match .sectionKey and addon ._optionsV2SectionFrames and addon ._optionsV2SectionFrames [match .pageKey ] then
430+ local sectionFrame = addon ._optionsV2SectionFrames [match .pageKey ][match .sectionKey ]
431+ if pageScroll and sectionFrame then
432+ -- Get the section's top position relative to the scroll child (pageContent)
433+ local pageContent = pageScroll :GetScrollChild ()
434+ if pageContent and sectionFrame :GetParent () == pageContent then
435+ -- Get section's relative position to its parent (pageContent)
436+ local numPoints = sectionFrame :GetNumPoints ()
437+ local targetScroll = 0
438+ for i = 1 , numPoints do
439+ local point , relativeTo , relativePoint , xOfs , yOfs = sectionFrame :GetPoint (i )
440+ if point and point :match (" ^TOP" ) and relativeTo == pageContent then
441+ -- Found a TOP anchor, use its Y offset (absolute value since negative = down)
442+ targetScroll = math.abs (yOfs or 0 ) - 50 -- Offset 50 pixels from top for visibility
443+ targetScroll = math.max (0 , targetScroll )
444+ break
445+ end
446+ end
447+ pageScroll :SetVerticalScroll (targetScroll )
448+ end
449+ end
450+ -- Find and highlight the specific control label that matches the search query
451+ local query = string.lower ((frame ._searchQuery or " " ):match (" ^%s*(.-)%s*$" ) or " " )
452+ if query ~= " " and sectionFrame then
453+ -- Check regions for FontStrings (control labels and text)
454+ local regions = sectionFrame .GetRegions and {sectionFrame :GetRegions ()} or {}
455+ for i = 1 , # regions do
456+ local region = regions [i ]
457+ if region and region .GetObjectType and region :GetObjectType () == " FontString" then
458+ local textContent = region :GetText () or " "
459+ local lowerText = string.lower (textContent )
460+ -- Check if this FontString contains the search query
461+ if lowerText :find (query , 1 , true ) then
462+ -- Store original color for restoration
463+ if not region .__searchOriginalColor then
464+ region .__searchOriginalColor = {region :GetTextColor ()}
465+ end
466+ -- Apply highlight color (bold effect by using accent color)
467+ local highlightColor = (currentStyle .accent or {0.74 , 0.58 , 0.99 })
468+ region :SetTextColor (highlightColor [1 ], highlightColor [2 ], highlightColor [3 ], 1 )
469+ -- Create pulsing effect that continues until search is cleared
470+ if C_Timer and C_Timer .NewTicker then
471+ -- Cancel any existing pulse timer for this region
472+ if region .__searchPulseTimer then
473+ region .__searchPulseTimer :Cancel ()
474+ end
475+ -- Track highlighted regions globally so we can cancel them when search clears
476+ addon ._searchHighlightedRegions = addon ._searchHighlightedRegions or {}
477+ table.insert (addon ._searchHighlightedRegions , region )
478+ -- Start pulsing between highlight and original color
479+ local isPulseOn = true
480+ region .__searchPulseTimer = C_Timer .NewTicker (0.5 , function ()
481+ if region and region .__searchOriginalColor then
482+ if isPulseOn then
483+ -- Pulse to original color
484+ region :SetTextColor (region .__searchOriginalColor [1 ], region .__searchOriginalColor [2 ], region .__searchOriginalColor [3 ], region .__searchOriginalColor [4 ] or 1 )
485+ else
486+ -- Pulse to highlight color
487+ region :SetTextColor (highlightColor [1 ], highlightColor [2 ], highlightColor [3 ], 1 )
488+ end
489+ isPulseOn = not isPulseOn
490+ end
491+ end )
492+ end
493+ break -- Only highlight the first match in the section
494+ end
495+ end
496+ end
497+ end
498+ end
499+ end )
500+ end
423501 local label = match .label or target .label or target .key
424502 searchStatus :SetText ((" %d/%d: %s" ):format (idx , # results , tostring (label )))
425503 else
@@ -574,6 +652,21 @@ function addon:CreateOptionsV2Window()
574652 frame ._searchIndex = nil
575653 if selfBox :GetText () == " " then
576654 searchStatus :SetText (" " )
655+ -- Cancel all active search highlight pulse timers
656+ if addon ._searchHighlightedRegions then
657+ for i , region in ipairs (addon ._searchHighlightedRegions ) do
658+ if region and region .__searchPulseTimer then
659+ region .__searchPulseTimer :Cancel ()
660+ region .__searchPulseTimer = nil
661+ end
662+ -- Restore original color
663+ if region and region .__searchOriginalColor then
664+ region :SetTextColor (region .__searchOriginalColor [1 ], region .__searchOriginalColor [2 ], region .__searchOriginalColor [3 ], region .__searchOriginalColor [4 ] or 1 )
665+ region .__searchOriginalColor = nil
666+ end
667+ end
668+ addon ._searchHighlightedRegions = {}
669+ end
577670 end
578671 end
579672 end )
@@ -587,6 +680,21 @@ function addon:CreateOptionsV2Window()
587680 frame ._searchQuery = nil
588681 frame ._searchResults = nil
589682 frame ._searchIndex = nil
683+ -- Cancel all active search highlight pulse timers
684+ if addon ._searchHighlightedRegions then
685+ for i , region in ipairs (addon ._searchHighlightedRegions ) do
686+ if region and region .__searchPulseTimer then
687+ region .__searchPulseTimer :Cancel ()
688+ region .__searchPulseTimer = nil
689+ end
690+ -- Restore original color
691+ if region and region .__searchOriginalColor then
692+ region :SetTextColor (region .__searchOriginalColor [1 ], region .__searchOriginalColor [2 ], region .__searchOriginalColor [3 ], region .__searchOriginalColor [4 ] or 1 )
693+ region .__searchOriginalColor = nil
694+ end
695+ end
696+ addon ._searchHighlightedRegions = {}
697+ end
590698 end )
591699 searchBox :SetScript (" OnKeyDown" , function (selfBox , key )
592700 if key == " UP" then
0 commit comments