private igInputText ( string label, |
||
label | string | |
buffer | ||
buf_size | uint | |
flags | InputTextFlags | |
callback | TextEditCallback | |
user_data | void | |
return | bool |
public static bool InputText( string label, IntPtr buf, uint buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, IntPtr user_data) { int utf8LabelByteCount = Encoding.UTF8.GetByteCount(label); byte *utf8LabelBytes; if (utf8LabelByteCount > Util.StackAllocationSizeLimit) { utf8LabelBytes = Util.Allocate(utf8LabelByteCount + 1); } else { byte *stackPtr = stackalloc byte[utf8LabelByteCount + 1]; utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); bool ret = ImGuiNative.igInputText(utf8LabelBytes, (byte *)buf.ToPointer(), buf_size, flags, callback, user_data.ToPointer()) != 0; if (utf8LabelByteCount > Util.StackAllocationSizeLimit) { Util.Free(utf8LabelBytes); } return(ret); }
public static bool InputText( string label, IntPtr buf, uint buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, IntPtr user_data) { int labelByteCount = Encoding.UTF8.GetByteCount(label); byte *labelBytes = stackalloc byte[labelByteCount]; fixed(char *labelPtr = label) { Encoding.UTF8.GetBytes(labelPtr, label.Length, labelBytes, labelByteCount); } return(ImGuiNative.igInputText(labelBytes, (byte *)buf.ToPointer(), buf_size, flags, callback, user_data.ToPointer()) != 0); }
public static bool InputText( string label, ref string input, uint maxLength, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, IntPtr user_data) { int labelByteCount = Encoding.UTF8.GetByteCount(label); byte *labelBytes = stackalloc byte[labelByteCount]; fixed(char *labelPtr = label) { Encoding.UTF8.GetBytes(labelPtr, label.Length, labelBytes, labelByteCount); } int originalByteCount = Encoding.UTF8.GetByteCount(input); int stackBufSize = Math.Max((int)maxLength, originalByteCount); byte *bufBytes = stackalloc byte[stackBufSize]; fixed(char *u16Ptr = input) { Encoding.UTF8.GetBytes(u16Ptr, input.Length, bufBytes, stackBufSize); } byte *originalBufBytes = stackalloc byte[originalByteCount]; Unsafe.CopyBlock(originalBufBytes, bufBytes, (uint)originalByteCount); byte result = ImGuiNative.igInputText( labelBytes, bufBytes, (uint)stackBufSize, flags, callback, user_data.ToPointer()); if (!Util.AreStringsEqual(originalBufBytes, originalByteCount, bufBytes)) { input = Util.StringFromPtr(bufBytes); } return(result != 0); }
public static unsafe bool InputText(string label, IntPtr textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback, IntPtr userData) { return(ImGuiNative.igInputText(label, textBuffer, bufferSize, flags, textEditCallback, userData.ToPointer())); }
public static bool InputText( string label, ref string input, uint maxLength, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, IntPtr user_data) { int utf8LabelByteCount = Encoding.UTF8.GetByteCount(label); byte *utf8LabelBytes; if (utf8LabelByteCount > Util.StackAllocationSizeLimit) { utf8LabelBytes = Util.Allocate(utf8LabelByteCount + 1); } else { byte *stackPtr = stackalloc byte[utf8LabelByteCount + 1]; utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); byte *utf8InputBytes; byte *originalUtf8InputBytes; if (inputBufSize > Util.StackAllocationSizeLimit) { utf8InputBytes = Util.Allocate(inputBufSize); originalUtf8InputBytes = Util.Allocate(inputBufSize); } else { byte *inputStackBytes = stackalloc byte[inputBufSize]; utf8InputBytes = inputStackBytes; byte *originalInputStackBytes = stackalloc byte[inputBufSize]; originalUtf8InputBytes = originalInputStackBytes; } Util.GetUtf8(input, utf8InputBytes, inputBufSize); uint clearBytesCount = (uint)(inputBufSize - utf8InputByteCount); Unsafe.InitBlockUnaligned(utf8InputBytes + utf8InputByteCount, 0, clearBytesCount); Unsafe.CopyBlock(originalUtf8InputBytes, utf8InputBytes, (uint)inputBufSize); byte result = ImGuiNative.igInputText( utf8LabelBytes, utf8InputBytes, (uint)inputBufSize, flags, callback, user_data.ToPointer()); if (!Util.AreStringsEqual(originalUtf8InputBytes, inputBufSize, utf8InputBytes)) { input = Util.StringFromPtr(utf8InputBytes); } if (utf8LabelByteCount > Util.StackAllocationSizeLimit) { Util.Free(utf8LabelBytes); } if (inputBufSize > Util.StackAllocationSizeLimit) { Util.Free(utf8InputBytes); Util.Free(originalUtf8InputBytes); } return(result != 0); }