UE4笔记--创建右键菜单


UE4笔记--创建右键菜单
FVRSMainFrameCommands 部分可以查看UE源码中的FMainFrameCommands代码


FReply SVRSTutorialButton::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
	if (MouseEvent.GetEffectingButton() == EKeys::RightMouseButton)
	{
		const bool bInShouldCloseWindowAfterMenuSelection = true;
		FMenuBuilder MenuBuilder(bInShouldCloseWindowAfterMenuSelection, FVRSMainFrameCommands::ActionList);

		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_Clone);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Group_Group);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Group_Ungroup);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_Copy);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_Paste);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_Delete);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_MirrorX);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_MirrorY);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_SnapFloor);
		MenuBuilder.AddMenuEntry(FVRSMainFrameCommands::Get().Edit_Detail);

		FWidgetPath WidgetPath = MouseEvent.GetEventPath() != nullptr ? *MouseEvent.GetEventPath() : FWidgetPath();
		FSlateApplication::Get().PushMenu(SharedThis(this), WidgetPath, MenuBuilder.MakeWidget(), FSlateApplication::Get().GetCursorPos(), FPopupTransitionEffect::ContextMenu);
	}
	return FReply::Handled();
}


你可能感兴趣的:(UE4学习笔记)