internal static bool OnProcess(int ID, ref string Text, LGuiRect Rect, uint MaxLength, LGuiInputTextFlags Flags, Func <char, bool> Callback)
        {
            var RenderPos = new LGuiVec2(Rect.X + 3, Rect.Y + 1);

            var Info = new LGuiTextRenderInfo();

            Info.TextColor  = LGuiStyle.GetColor(LGuiStyleColorIndex.Text);
            Info.Font       = LGuiContext.Font;
            Info.IsHidden   = (Flags & LGuiInputTextFlags.Password) == LGuiInputTextFlags.Password;
            Info.HiddenChar = '*';
            Info.CountX     = (uint)LGuiMisc.Floor((Rect.Width - 6) / Info.Font.FontWidth);
            Info.CountY     = (Flags & LGuiInputTextFlags.Multiline) == LGuiInputTextFlags.Multiline
                ? (uint)LGuiMisc.Floor((Rect.Height - 2) / Info.Font.FontHeight)
                : 1u;

            Info.OnlyShowText = false;
            if ((Flags & LGuiInputTextFlags.OnlyDisplay) == LGuiInputTextFlags.OnlyDisplay)
            {
                Info.Text         = Text;
                Info.OnlyShowText = true;

                LGuiTextRenderer.Render(Info, RenderPos);
                return(false);
            }

            if (CurrentState == null || CurrentState.ID != ID)
            {
                CurrentState = new LGuiTextFieldState(ID, Text, (Flags & LGuiInputTextFlags.Multiline) != LGuiInputTextFlags.Multiline);
                if ((Flags & LGuiInputTextFlags.AutoSelectAll) == LGuiInputTextFlags.AutoSelectAll)
                {
                    CurrentState.SelectAll();
                }
            }
            HandleKeyEvent(CurrentState, Flags, Callback);
            HandleMouseEvent(CurrentState, Info.Font, RenderPos);

            CurrentState.MaxLength = MaxLength;
            Info.CursorColor       = Info.TextColor;
            if ((Flags & LGuiInputTextFlags.InsertMode) == LGuiInputTextFlags.InsertMode)
            {
                CurrentState.InsertMode = true;
                Info.CursorWidth        = 1u;
                Info.CursorColor.A      = 0.5f;
            }
            else
            {
                Info.CursorWidth = 0u;
            }

            var Cursor = (uint)CurrentState.GetCursor();

            if (Cursor < CurrentState.OffsetX)
            {
                CurrentState.OffsetX = Cursor;
            }
            else if (Cursor > CurrentState.OffsetX + Info.CountX)
            {
                CurrentState.OffsetX = Cursor - Info.CountX;
            }

            Info.Text        = CurrentState.Text;
            Info.SelectStart = (uint)CurrentState.GetSelectStart();
            Info.SelectEnd   = (uint)CurrentState.GetSelectEnd();
            Info.SelectColor = LGuiColor.Blue;
            Info.Spacing     = CurrentState.Spacing;

            Info.Cursor  = Cursor;
            Info.OffsetX = CurrentState.OffsetX;
            Info.OffsetY = CurrentState.OffsetY;

            LGuiTextRenderer.Render(Info, RenderPos);

            if ((Flags & LGuiInputTextFlags.EnterReturnsTrue) == LGuiInputTextFlags.EnterReturnsTrue)
            {
                Text = CurrentState.Text;
                var ValueChanged = LGuiContext.IO.IsKeyPressed(LGuiKeys.Enter);
                if (ValueChanged)
                {
                    LGuiContext.FocusID = 0;
                }
                return(ValueChanged);
            }
            else
            {
                var NewText      = CurrentState.Text;
                var ValueChanged = NewText != Text;
                Text = NewText;
                return(ValueChanged);
            }
        }
        private static void HandleKeyEvent(LGuiTextFieldState State, LGuiInputTextFlags Flags, Func <char, bool> Callback)
        {
            var KeyCode = LGuiContext.IO.KeyCode;

            if (KeyCode == LGuiKeys.None)
            {
                return;
            }

            if (!LGuiContext.IO.IsKeyPressed(KeyCode))
            {
                return;
            }

            var CmdKey = LGuiTextFieldCmdKey.None;
            var Ctrl   = LGuiContext.IO.IsKeyDown(LGuiKeys.Control);
            var Shift  = LGuiContext.IO.IsKeyDown(LGuiKeys.Shift);
            var Alt    = LGuiContext.IO.IsKeyDown(LGuiKeys.Alt);

            var ReadOnly   = (Flags & LGuiInputTextFlags.Readonly) == LGuiInputTextFlags.Readonly;
            var NoUndoRedo = (Flags & LGuiInputTextFlags.NoUndoRedo) == LGuiInputTextFlags.NoUndoRedo;

            switch (KeyCode)
            {
            case LGuiKeys.Left:
                CmdKey = LGuiTextFieldCmdKey.Left;
                break;

            case LGuiKeys.Right:
                CmdKey = LGuiTextFieldCmdKey.Right;
                break;

            case LGuiKeys.Up:
                CmdKey = LGuiTextFieldCmdKey.Up;
                break;

            case LGuiKeys.Down:
                CmdKey = LGuiTextFieldCmdKey.Down;
                break;

            case LGuiKeys.Home:
                CmdKey = LGuiTextFieldCmdKey.Home;
                break;

            case LGuiKeys.End:
                CmdKey = LGuiTextFieldCmdKey.End;
                break;

            case LGuiKeys.CapsLock:
                State.CapsLock = !State.CapsLock;
                break;

            case LGuiKeys.Insert:
                State.InsertMode = !State.InsertMode;
                break;

            case LGuiKeys.Backspace:
                if (!ReadOnly)
                {
                    CmdKey = LGuiTextFieldCmdKey.Backspace;
                }
                break;

            case LGuiKeys.Delete:
                if (!ReadOnly)
                {
                    CmdKey = LGuiTextFieldCmdKey.Delete;
                }
                break;

            case LGuiKeys.A:
                if (Ctrl)
                {
                    State.SelectAll();
                }
                else
                {
                    CmdKey = LGuiTextFieldCmdKey.Character;
                }
                break;

            case LGuiKeys.C:
                if (!ReadOnly)
                {
                    CmdKey = Ctrl ? LGuiTextFieldCmdKey.Copy : LGuiTextFieldCmdKey.Character;
                }
                break;

            case LGuiKeys.V:
                if (!ReadOnly)
                {
                    CmdKey = Ctrl ? LGuiTextFieldCmdKey.Paste : LGuiTextFieldCmdKey.Character;
                }
                break;

            case LGuiKeys.X:
                if (!ReadOnly)
                {
                    CmdKey = Ctrl ? LGuiTextFieldCmdKey.Cut : LGuiTextFieldCmdKey.Character;
                }
                break;

            case LGuiKeys.Y:
                if (!ReadOnly && !NoUndoRedo)
                {
                    CmdKey = Ctrl ? LGuiTextFieldCmdKey.Redo : LGuiTextFieldCmdKey.Character;
                }
                break;

            case LGuiKeys.Z:
                if (!ReadOnly && !NoUndoRedo)
                {
                    CmdKey = Ctrl ? LGuiTextFieldCmdKey.Undo : LGuiTextFieldCmdKey.Character;
                }
                break;

            case LGuiKeys.Control:
            case LGuiKeys.Shift:
            case LGuiKeys.Alt:
                break;

            default:
                if (!ReadOnly)
                {
                    CmdKey = LGuiTextFieldCmdKey.Character;
                }
                break;
            }

            if (CmdKey == LGuiTextFieldCmdKey.None)
            {
                return;
            }

            if (Ctrl)
            {
                CmdKey |= LGuiTextFieldCmdKey.Ctrl;
            }

            if (Shift)
            {
                CmdKey |= LGuiTextFieldCmdKey.Shift;
            }

            if (Alt)
            {
                CmdKey |= LGuiTextFieldCmdKey.Alt;
            }

            var Ch     = ParseKeyCharacter(KeyCode, Shift, State.CapsLock);
            var Filter = new LGuiTextFieldInputFilter(Flags, Callback);

            if (!Filter.Parse(ref Ch))
            {
                Ch = (char)0;
            }

            State.OnCmdKey(CmdKey, Ch);
        }