void FLevelEditorContextMenu::SummonMenu( const TSharedRef< SLevelEditor >& LevelEditor, LevelEditorMenuContext ContextType ) { struct Local { static void ExtendMenu( FMenuBuilder& MenuBuilder ) { // one extra entry when summoning the menu this way MenuBuilder.BeginSection("ActorPreview", LOCTEXT("PreviewHeading", "Preview") ); { // Note: not using a command for play from here since it requires a mouse click FUIAction PlayFromHereAction( FExecuteAction::CreateStatic( &FPlayWorldCommandCallbacks::StartPlayFromHere ) ); const FText PlayFromHereLabel = GEditor->OnlyLoadEditorVisibleLevelsInPIE() ? LOCTEXT("PlayFromHereVisible", "Play From Here (visible levels)") : LOCTEXT("PlayFromHere", "Play From Here"); MenuBuilder.AddMenuEntry( PlayFromHereLabel, LOCTEXT("PlayFromHere_ToolTip", "Starts a game preview from the clicked location"),FSlateIcon(), PlayFromHereAction ); } MenuBuilder.EndSection(); } }; TSharedRef<FExtender> Extender = MakeShareable(new FExtender); Extender->AddMenuExtension("LevelViewportAttach", EExtensionHook::After, TSharedPtr< FUICommandList >(), FMenuExtensionDelegate::CreateStatic(&Local::ExtendMenu)); // Create the context menu! TSharedPtr<SWidget> MenuWidget = BuildMenuWidget( LevelEditor, ContextType, Extender ); if ( MenuWidget.IsValid() ) { // @todo: Should actually use the location from a click event instead! const FVector2D MouseCursorLocation = FSlateApplication::Get().GetCursorPos(); TWeakPtr< SWindow > ContextMenuWindow = FSlateApplication::Get().PushMenu( LevelEditor->GetActiveViewport().ToSharedRef(), MenuWidget.ToSharedRef(), MouseCursorLocation, FPopupTransitionEffect( FPopupTransitionEffect::ContextMenu ) ); } }