Skip to content

Commit

Permalink
feat: add clipboard MonoPInvoke
Browse files Browse the repository at this point in the history
  • Loading branch information
Rofli Sanches committed May 21, 2021
1 parent f468a58 commit 3d68712
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions Source/Platform/PlatformCallbacks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ImGuiNET;
using AOT;
using ImGuiNET;
using System;
using System.Runtime.InteropServices;
using UnityEngine;
Expand Down Expand Up @@ -41,8 +42,39 @@ internal unsafe class PlatformCallbacks
private static GetClipboardTextCallback _getClipboardText;
private static SetClipboardTextCallback _setClipboardText;

// TODO: Implement (check) this.
[MonoPInvokeCallback(typeof(GetClipboardTextCallback))]
public static unsafe string GetClipboardTextCallback(void* user_data)
{
return GUIUtility.systemCopyBuffer;
}

[MonoPInvokeCallback(typeof(SetClipboardTextCallback))]
public static unsafe void SetClipboardTextCallback(void* user_data, byte* text)
{
GUIUtility.systemCopyBuffer = Utils.StringFromPtr(text);
}

[MonoPInvokeCallback(typeof(ImeSetInputScreenPosCallback))]
public static unsafe void ImeSetInputScreenPosCallback(int x, int y)
{
Input.compositionCursorPos = new Vector2(x, y);
}

// TODO: IMGUI_FEATURE_CUSTOM_ASSERT.
#if IMGUI_FEATURE_CUSTOM_ASSERT
//[MonoPInvokeCallback(typeof(LogAssertCallback))]
//public unsafe static void LogAssertCallback(byte* condition, byte* file, int line)
//{
// Debug.LogError($"[DearImGui] Assertion failed: '{Util.StringFromPtr(condition)}', file '{Util.StringFromPtr(file)}', line: {line}.");
//}

//[MonoPInvokeCallback(typeof(DebugBreakCallback))]
//public unsafe static void DebugBreakCallback()
//{
// System.Diagnostics.Debugger.Break();
//}

// TODO: Implement (check) this.
//private static LogAssertCallback _logAssert;
//private static DebugBreakCallback _debugBreak;
#endif
Expand Down

0 comments on commit 3d68712

Please sign in to comment.