Skip to content

Commit c39ea4f

Browse files
committed
Add the CopySyncMemberToClipboardAction monkey from the Resonite Integration testing
This implements the feature requested in Yellow-Dog-Man/Resonite-Issues#810
1 parent 1b12e61 commit c39ea4f

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using FrooxEngine;
2+
using MonkeyLoader.Resonite;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace CommunityBugFixCollection
9+
{
10+
internal sealed class CopySyncMemberToClipboardAction
11+
: ResoniteAsyncEventHandlerMonkey<CopySyncMemberToClipboardAction, InspectorMemberActionsMenuItemsGenerationEvent>
12+
{
13+
public override int Priority => HarmonyLib.Priority.Normal;
14+
15+
protected override bool AppliesTo(InspectorMemberActionsMenuItemsGenerationEvent eventData)
16+
=> base.AppliesTo(eventData) && eventData.Target is IField;
17+
18+
protected override Task Handle(InspectorMemberActionsMenuItemsGenerationEvent eventData)
19+
{
20+
var field = (IField)eventData.Target;
21+
var menuItem = eventData.ContextMenu.AddItem("Copy to Clipboard",
22+
OfficialAssets.Graphics.Icons.General.Duplicate, RadiantUI_Constants.Sub.GREEN);
23+
24+
menuItem.Button.LocalPressed += (button, _) =>
25+
{
26+
button.World.InputInterface.Clipboard.SetText(field.BoxedValue.ToString());
27+
button.World.LocalUser.CloseContextMenu(eventData.MemberActions);
28+
};
29+
30+
return Task.CompletedTask;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)