public static void SetClipboardCallback(Action<string> onCopy, Func<string> onPaste) { unsafe { _onClipboardCopy = onCopy; _onClipboardPaste = onPaste; _nkOnClipboardCopy = (_, str, len) => { var bytes = new byte[len]; for (var i = 0; i < bytes.Length; i++) bytes[i] = str[i]; onCopy(Encoding.UTF8.GetString(bytes)); }; _nkOnClipboardPaste = (nk_handle _, ref nk_text_edit textEdit) => { var bytes = Encoding.UTF8.GetBytes(onPaste()); fixed (byte* bytesPtr = bytes) fixed (nk_text_edit* TextEditPtr = &textEdit) Nuklear.nk_textedit_paste(TextEditPtr, bytesPtr, bytes.Length); }; _nuklearContext->clip.copyfun_nkPluginCopyT = Marshal.GetFunctionPointerForDelegate(_nkOnClipboardCopy); _nuklearContext->clip.pastefun_nkPluginPasteT = Marshal.GetFunctionPointerForDelegate(_nkOnClipboardPaste); } }