/// <summary>
        /// Method returns true if input was captured by control, so no other controls, nor screen can use input in this update
        /// </summary>
        public override MyGuiControlBase HandleInput()
        {
            MyGuiControlBase ret = base.HandleInput();

            try
            {
                if (ret == null && Enabled)
                {
                    if (MyInput.Static.IsNewLeftMousePressed())
                    {
                        if (IsMouseOver)
                        {
                            m_selection.Dragging  = true;
                            CarriagePositionIndex = GetCarriagePositionFromMouseCursor();
                            if (MyInput.Static.IsAnyShiftKeyPressed())
                            {
                                m_selection.SetEnd(this);
                            }
                            else
                            {
                                m_selection.Reset(this);
                            }
                            ret = this;
                        }
                        else
                        {
                            m_selection.Reset(this);
                        }
                    }
                    else if (MyInput.Static.IsNewLeftMouseReleased())
                    {
                        m_selection.Dragging = false;
                    }
                    else if (m_selection.Dragging)
                    {
                        CarriagePositionIndex = GetCarriagePositionFromMouseCursor();
                        m_selection.SetEnd(this);
                        ret = this;
                    }

                    if (HasFocus)
                    {
                        if (!MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            HandleTextInputBuffered(ref ret);
                        }

                        //  Move left
                        if (m_keyThrottler.GetKeyStatus(MyKeys.Left) == ThrottledKeyStatus.PRESSED_AND_READY)
                        {
                            if (MyInput.Static.IsAnyCtrlKeyPressed())
                            {
                                CarriagePositionIndex = GetPreviousSpace();
                            }
                            else
                            {
                                CarriagePositionIndex--;
                            }

                            if (MyInput.Static.IsAnyShiftKeyPressed())
                            {
                                m_selection.SetEnd(this);
                            }
                            else
                            {
                                m_selection.Reset(this);
                            }

                            ret = this;
                        }

                        //  Move right
                        if (m_keyThrottler.GetKeyStatus(MyKeys.Right) == ThrottledKeyStatus.PRESSED_AND_READY)
                        {
                            if (MyInput.Static.IsAnyCtrlKeyPressed())
                            {
                                CarriagePositionIndex = GetNextSpace();
                            }
                            else
                            {
                                CarriagePositionIndex++;
                            }

                            if (MyInput.Static.IsAnyShiftKeyPressed())
                            {
                                m_selection.SetEnd(this);
                            }
                            else
                            {
                                m_selection.Reset(this);
                            }

                            ret = this;
                        }

                        //  Move home
                        if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.Home))
                        {
                            CarriagePositionIndex = 0;

                            if (MyInput.Static.IsAnyShiftKeyPressed())
                            {
                                m_selection.SetEnd(this);
                            }
                            else
                            {
                                m_selection.Reset(this);
                            }

                            ret = this;
                        }

                        //  Move end
                        if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.End))
                        {
                            CarriagePositionIndex = m_text.Length;

                            if (MyInput.Static.IsAnyShiftKeyPressed())
                            {
                                m_selection.SetEnd(this);
                            }
                            else
                            {
                                m_selection.Reset(this);
                            }

                            ret = this;
                        }

                        //Cut selected text
                        if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.X) && MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            m_selection.CutText(this);
                        }

                        //Copy
                        if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.C) && MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            m_selection.CopyText(this);
                        }

                        //Paste
                        if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.V) && MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            m_selection.PasteText(this);
                        }

                        //Select All
                        if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.A) && MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            m_selection.SelectAll(this);
                        }

                        if (MyInput.Static.IsNewKeyPressed(MyKeys.Enter))
                        {
                            if (EnterPressed != null)
                            {
                                EnterPressed(this);
                            }
                        }

                        m_formattedAlready = false;
                    }
                    else
                    {
                        if (Type == MyGuiControlTextboxType.DigitsOnly && m_formattedAlready == false && m_text.Length != 0)
                        {
                            var number        = MyValueFormatter.GetDecimalFromString(Text, 1);
                            int decimalDigits = (number - Decimal.Truncate(number) > 0) ? 1 : 0;
                            m_text.Clear().Append(MyValueFormatter.GetFormatedFloat((float)number, decimalDigits, ""));
                            CarriagePositionIndex = m_text.Length;
                            m_formattedAlready    = true;
                        }
                    }
                }
            }
            catch (IndexOutOfRangeException) // mkTODO: Why? Handle correctly
            {
            }

            m_hadFocusLastTime = HasFocus;
            return(ret);
        }
        public override MyGuiControlBase HandleInput()
        {
            MyGuiControlBase baseResult = base.HandleInput();

            if (HasFocus && Selectable)
            {
                //  Move left
                switch (m_keyThrottler.GetKeyStatus(MyKeys.Left))
                {
                case ThrottledKeyStatus.PRESSED_AND_WAITING:
                    return(this);

                case ThrottledKeyStatus.PRESSED_AND_READY:
                    if (MyInput.Static.IsAnyCtrlKeyPressed())
                    {
                        CarriagePositionIndex = GetPreviousSpace();
                    }
                    else
                    {
                        CarriagePositionIndex--;
                    }

                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        m_selection.SetEnd(this);
                    }
                    else
                    {
                        m_selection.Reset(this);
                    }
                    return(this);
                }

                //  Move right
                switch (m_keyThrottler.GetKeyStatus(MyKeys.Right))
                {
                case ThrottledKeyStatus.PRESSED_AND_WAITING:
                    return(this);

                case ThrottledKeyStatus.PRESSED_AND_READY:
                    if (MyInput.Static.IsAnyCtrlKeyPressed())
                    {
                        CarriagePositionIndex = GetNextSpace();
                    }
                    else
                    {
                        ++CarriagePositionIndex;
                    }
                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        m_selection.SetEnd(this);
                    }
                    else
                    {
                        m_selection.Reset(this);
                    }
                    return(this);
                }

                //  Move Down
                switch (m_keyThrottler.GetKeyStatus(MyKeys.Down))
                {
                case ThrottledKeyStatus.PRESSED_AND_WAITING:
                    return(this);

                case ThrottledKeyStatus.PRESSED_AND_READY:
                    CarriagePositionIndex = GetIndexUnderCarriage(CarriagePositionIndex);
                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        m_selection.SetEnd(this);
                    }
                    else
                    {
                        m_selection.Reset(this);
                    }
                    return(this);
                }

                //  Move Up
                switch (m_keyThrottler.GetKeyStatus(MyKeys.Up))
                {
                case ThrottledKeyStatus.PRESSED_AND_WAITING:
                    return(this);

                case ThrottledKeyStatus.PRESSED_AND_READY:
                    CarriagePositionIndex = GetIndexOverCarriage(CarriagePositionIndex);
                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        m_selection.SetEnd(this);
                    }
                    else
                    {
                        m_selection.Reset(this);
                    }
                    return(this);
                }

                //Copy
                if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.C) && MyInput.Static.IsAnyCtrlKeyPressed())
                {
                    m_selection.CopyText(this);
                }

                //Select All
                if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.A) && MyInput.Static.IsAnyCtrlKeyPressed())
                {
                    m_selection.SelectAll(this);
                    return(this);
                }
            }

            //scroll
            bool captured   = false;
            var  deltaWheel = MyInput.Static.DeltaMouseScrollWheelValue();

            if (IsMouseOver && deltaWheel != 0)
            {
                m_scrollbar.ChangeValue(-0.0005f * deltaWheel);
                captured = true;
            }

            if (m_drawScrollbar)
            {
                bool capturedScrollbar = m_scrollbar.HandleInput();

                if (capturedScrollbar || captured)
                {
                    return(this);
                }
            }

            if (IsMouseOver && m_label.HandleInput(GetPositionAbsoluteTopLeft(), m_scrollbar.Value))
            {
                return(this);
            }

            if (Selectable)
            {
                if (MyInput.Static.IsNewLeftMousePressed())
                {
                    if (IsMouseOver)
                    {
                        m_selection.Dragging  = true;
                        CarriagePositionIndex = GetCarriagePositionFromMouseCursor();
                        if (MyInput.Static.IsAnyShiftKeyPressed())
                        {
                            m_selection.SetEnd(this);
                        }
                        else
                        {
                            m_selection.Reset(this);
                        }
                        return(this);
                    }
                    else
                    {
                        m_selection.Reset(this);
                    }
                }

                else if (MyInput.Static.IsNewLeftMouseReleased())
                {
                    m_selection.Dragging = false;
                }

                //user holding the mouse button
                else if (m_selection.Dragging)
                {
                    //If inside, we update selection and move the carriage (dragging what you want to select)
                    if (IsMouseOver)
                    {
                        CarriagePositionIndex = GetCarriagePositionFromMouseCursor();
                        m_selection.SetEnd(this);
                    }

                    //Otherwise, do the "scroll along with selection" effect
                    else if (HasFocus)
                    {
                        Vector2 mousePos        = MyGuiManager.MouseCursorPosition;
                        Vector2 positionTopLeft = GetPositionAbsoluteTopLeft();
                        if (mousePos.Y < positionTopLeft.Y)
                        {
                            m_scrollbar.ChangeValue(Position.Y - mousePos.Y);
                        }
                        else if (mousePos.Y > positionTopLeft.Y + Size.Y)
                        {
                            m_scrollbar.ChangeValue(mousePos.Y - positionTopLeft.Y - Size.Y);
                        }
                    }
                }
            }

            return(baseResult);
        }