FReply SVisualLoggerLogsList::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) { if (InKeyEvent.GetKey() == EKeys::C && (InKeyEvent.IsLeftCommandDown() || InKeyEvent.IsLeftControlDown())) { FString ClipboardString; for (const TSharedPtr<struct FLogEntryItem>& CurrentItem : LogsLinesWidget->GetSelectedItems()) { ClipboardString += CurrentItem->Category + FString(TEXT(" (")) + FString(FOutputDevice::VerbosityToString(CurrentItem->Verbosity)) + FString(TEXT(") ")) + CurrentItem->Line; ClipboardString += TEXT("\n"); } FPlatformMisc::ClipboardCopy(*ClipboardString); return FReply::Handled(); } return FReply::Unhandled(); }
FReply SVisualLoggerTimelinesContainer::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) { if (InKeyEvent.GetKey() == EKeys::A && InKeyEvent.IsLeftControlDown()) { for (TSharedPtr<SLogVisualizerTimeline>& Timeline : TimelineItems) { SetSelectionState(Timeline, true, false); } return FReply::Handled(); } else if (InKeyEvent.GetKey() == EKeys::Platform_Delete && CachedSelectedTimelines.Num() > 0) { TWeakPtr<SLogVisualizerTimeline> NotSelectedOne; for (TSharedPtr<SLogVisualizerTimeline>& CurrentNode : CachedSelectedTimelines) { TSharedPtr<SLogVisualizerTimeline> LastSelected = CachedSelectedTimelines[CachedSelectedTimelines.Num() - 1]; bool bFoundSelectedOne = false; for (TSharedPtr<SLogVisualizerTimeline>& Timeline : TimelineItems) { if (IsNodeSelected(Timeline) == false) { NotSelectedOne = Timeline; } if (LastSelected == Timeline) { if (bFoundSelectedOne && NotSelectedOne.IsValid()) { break; } bFoundSelectedOne = true; } } FVisualLoggerDatabase::Get().RemoveRow(CurrentNode->GetName()); TimelineItems.Remove(CurrentNode); ContainingBorder->RemoveSlot(CurrentNode.ToSharedRef()); } if (NotSelectedOne.IsValid()) { SetSelectionState(NotSelectedOne.Pin(), true, true); } return FReply::Handled(); } else if (InKeyEvent.GetKey() == EKeys::Up || InKeyEvent.GetKey() == EKeys::Down) { TSharedPtr<SLogVisualizerTimeline> PreviousTimeline; TSharedPtr<SLogVisualizerTimeline> LastSelected = CachedSelectedTimelines[CachedSelectedTimelines.Num() - 1]; for (int32 Index = 0; Index < TimelineItems.Num(); ++Index) { auto& CurrentItem = TimelineItems[Index]; if (LastSelected == CurrentItem) { if (InKeyEvent.GetKey() == EKeys::Up && PreviousTimeline.IsValid()) { SetSelectionState(PreviousTimeline, true, true); } else if (InKeyEvent.GetKey() == EKeys::Down) { // let's find next visible time line if (TimelineItems.IsValidIndex(Index + 1)) { for (int32 i = Index + 1; i < TimelineItems.Num(); ++i) { if (TimelineItems[i]->GetVisibility() == EVisibility::Visible) { SetSelectionState(TimelineItems[i], true, true); break; } } } } break; } if (CurrentItem->GetVisibility() == EVisibility::Visible) { PreviousTimeline = CurrentItem; } } return FReply::Handled(); } return FReply::Unhandled(); }