Skip to content

Commit 74a6000

Browse files
committed
Fixed problem with finding row in StringTable
1 parent 42665fa commit 74a6000

1 file changed

Lines changed: 64 additions & 29 deletions

File tree

Source/StringTableSearchPlugin/Private/SlateWidgets/CoincidenceWidget.cpp

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "IContentBrowserSingleton.h"
88
#include "HAL/PlatformApplicationMisc.h"
99
#include "Internationalization/StringTable.h"
10+
#include "Slate/Private/Framework/Docking/SDockingArea.h"
1011
#include "Widgets/Input/SSearchBox.h"
1112

1213
void SCoincidenceWidget::Construct(const FArguments& InArgs)
@@ -274,7 +275,6 @@ FReply SCoincidenceWidget::OnStringTableMouseButtonUp(const FGeometry& Geometry,
274275
return FReply::Unhandled();
275276
}
276277

277-
//TODO: Fix problem with finding row in StringTable
278278
FReply SCoincidenceWidget::OnElementMouseDoubleClick(const FGeometry& Geometry, const FPointerEvent& MouseEvent, FString Key) const
279279
{
280280
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
@@ -304,40 +304,75 @@ FReply SCoincidenceWidget::OnElementMouseDoubleClick(const FGeometry& Geometry,
304304
EditorWindow = Window;
305305
break;
306306
}
307+
else
308+
{
309+
TFunction<void(const TSharedRef<SWidget>&)> FindDockTabsRecursive;
310+
311+
FindDockTabsRecursive = [&](const TSharedRef<SWidget>& Widget)
312+
{
313+
if (Widget->GetTypeAsString() == "SDockTab")
314+
{
315+
TSharedRef<const SDockTab> DockTab = StaticCastSharedRef<const SDockTab>(Widget);
316+
FString TabText = DockTab->GetTabLabel().ToString();
317+
318+
UE_LOG(LogTemp, Warning, TEXT("%s"), *TabText );
319+
320+
if (TabText.Contains(AssetData->AssetName.ToString()))
321+
{
322+
UE_LOG(LogTemp, Warning, TEXT("%s"), *DockTab->GetTabLabel().ToString() );
323+
EditorWindow = Window;
324+
return;
325+
}
326+
}
327+
const FChildren* Children = Widget->GetChildren();
328+
if (Children)
329+
{
330+
for (int32 i = 0; i < Children->Num(); ++i)
331+
{
332+
TSharedRef<SWidget> Child = ConstCastSharedRef<SWidget>(Children->GetChildAt(i));
333+
FindDockTabsRecursive(Child);
334+
}
335+
}
336+
};
337+
338+
FindDockTabsRecursive(Window);
339+
340+
if (EditorWindow != nullptr) break;
341+
}
307342
}
308-
}
309343

310-
if (EditorWindow.IsValid())
311-
{
312-
TSharedPtr<SWidget> FoundSearchBox;
344+
if (EditorWindow.IsValid())
345+
{
346+
TSharedPtr<SWidget> FoundSearchBox;
313347

314-
TFunction<void(TSharedRef<SWidget>)> WidgetSearch = [&](const TSharedRef<SWidget>& Widget)
315-
{
316-
if (!FoundSearchBox.IsValid() && Widget->GetTypeAsString() == "SSearchBox")
317-
{
318-
FoundSearchBox = Widget;
319-
}
348+
TFunction<void(TSharedRef<SWidget>)> WidgetSearch = [&](const TSharedRef<SWidget>& Widget)
349+
{
350+
if (!FoundSearchBox.IsValid() && Widget->GetTypeAsString() == "SSearchBox")
351+
{
352+
FoundSearchBox = Widget;
353+
}
320354

321-
if (!FoundSearchBox.IsValid())
322-
{
323-
FChildren* Children = Widget->GetChildren();
324-
for (int32 i = 0; i < Children->Num() && !FoundSearchBox.IsValid(); ++i)
325-
{
326-
WidgetSearch(Children->GetChildAt(i));
327-
}
328-
}
329-
};
355+
if (!FoundSearchBox.IsValid())
356+
{
357+
FChildren* Children = Widget->GetChildren();
358+
for (int32 i = 0; i < Children->Num() && !FoundSearchBox.IsValid(); ++i)
359+
{
360+
WidgetSearch(Children->GetChildAt(i));
361+
}
362+
}
363+
};
330364

331-
WidgetSearch(EditorWindow.ToSharedRef());
365+
WidgetSearch(EditorWindow.ToSharedRef());
332366

333-
if (FoundSearchBox.IsValid())
334-
{
335-
if (TSharedPtr<SSearchBox> SearchBox = StaticCastSharedPtr<SSearchBox>(FoundSearchBox))
336-
{
337-
SearchBox->SetText(FText::FromString(Key));
338-
}
339-
}
340-
}
367+
if (FoundSearchBox.IsValid())
368+
{
369+
if (TSharedPtr<SSearchBox> SearchBox = StaticCastSharedPtr<SSearchBox>(FoundSearchBox))
370+
{
371+
SearchBox->SetText(FText::FromString(Key));
372+
}
373+
}
374+
}
375+
}
341376
}
342377
}
343378
}

0 commit comments

Comments
 (0)