Exemplo n.º 1
0
 public void Unfocus()
 {
     if (focused)
     {
         focused = false;
         OnUnfocus?.Invoke();
     }
 }
Exemplo n.º 2
0
        public void Unfocus()
        {
            if (focused)
            {
                focused         = false;
                Main.blockInput = false;

                OnUnfocus?.Invoke();
            }
        }
Exemplo n.º 3
0
        public void Unfocus()
        {
            if (focused)
            {
                focused         = false;
                Main.blockInput = false;

                OnUnfocus?.Invoke();
                //WheresMyItemsUI.visible = false;
            }
        }
Exemplo n.º 4
0
        public override void Update(GameTime gameTime)
        {
            Vector2 MousePosition = new Vector2((float)Main.mouseX, (float)Main.mouseY);

            if (!ContainsPoint(MousePosition) && Main.mouseLeft)             // TODO: && focused maybe?
            {
                Focused = false;
                OnUnfocus?.Invoke(this, new EventArgs());
            }
            base.Update(gameTime);
        }
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            base.DrawSelf(spriteBatch);
            //Rectangle hitbox = GetInnerDimensions().ToRectangle();
            //Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.Red * 0.6f);

            if (Focused)
            {
                Terraria.GameInput.PlayerInput.WritingText = true;
                Main.instance.HandleIME();
                string newString = Main.GetInputText(CurrentString);
                if (!newString.Equals(CurrentString))
                {
                    CurrentString = newString;
                    OnTextChange?.Invoke(this);
                }
                else
                {
                    CurrentString = newString;
                }
                if (JustPressed(Keys.Tab))
                {
                    if (UnfocusOnTab)
                    {
                        Focused = false;
                        OnUnfocus?.Invoke(this);
                    }
                    OnTab?.Invoke(this);
                }
                if (++_textBlinkerCount >= 20)
                {
                    _textBlinkerState = (_textBlinkerState + 1) % 2;
                    _textBlinkerCount = 0;
                }
            }
            string displayString = CurrentString;

            if (_textBlinkerState == 1 && Focused)
            {
                displayString += "|";
            }
            CalculatedStyle space = GetDimensions();

            if (CurrentString.Length == 0 && !Focused)
            {
                Vector2 vector = Main.fontMouseText.MeasureString(_hintText);
                Utils.DrawBorderString(spriteBatch, _hintText, new Vector2(space.X + 6, space.Y + Height.Pixels - vector.Y - 5), Color.Gray);
            }
            else
            {
                Vector2 vector = Main.fontMouseText.MeasureString(displayString);
                Utils.DrawBorderString(spriteBatch, displayString, new Vector2(space.X + 6, space.Y + Height.Pixels - vector.Y - 5), Color.White);
            }
        }
        public override void Update(GameTime gameTime)
        {
            Vector2 point = new Vector2(Main.mouseX, Main.mouseY);

            if (!ContainsPoint(point) && Main.mouseLeft)
            {
                focused = false;
                OnUnfocus?.Invoke(this, new EventArgs());
            }

            base.Update(gameTime);
        }
Exemplo n.º 7
0
        /*protected override void DrawSelf(SpriteBatch spriteBatch)
         * {
         *  //Rectangle hitbox = GetInnerDimensions().ToRectangle();
         *  //Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.Blue);
         * }*/


        //void KeyboardInput_newKeyEvent(char obj)
        //{
        //	// Problem: keyBoardInput.newKeyEvent only fires on regular keyboard buttons.

        //	if (!focused) return;
        //	if (obj.Equals((char)Keys.Back)) // '\b'
        //	{
        //		Backspace();
        //	}
        //	else if (obj.Equals((char)Keys.Enter))
        //	{
        //		Unfocus();
        //		Main.chatRelease = false;
        //	}
        //	else if (Char.IsLetterOrDigit(obj))
        //	{
        //		Write(obj.ToString());
        //	}
        //}

        public void Unfocus()
        {
            if (focused)
            {
                focused         = false;
                Main.blockInput = false;

                //OnUnfocus?.Invoke();//#### need c# 6.0 is null? if not do it
                if (OnUnfocus != null)
                {
                    OnUnfocus.Invoke();
                }
            }
        }
Exemplo n.º 8
0
        public void Unfocus()
        {
            if (Focused)
            {
                foreach (var o in Options)
                {
                    o.Left.Set(-10000, 0);
                }
                OnUnfocus?.Invoke();

                ScaleUpBasedOnHover = true;

                Focused = false;
            }
        }
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            //base.DrawChildren(spriteBatch);
            if (focused)
            {
                PlayerInput.WritingText = true;
                Main.instance.HandleIME();
                string inputText = Main.GetInputText(currentText);

                if (!inputText.Equals(currentText))
                {
                    currentText = inputText;
                    OnTextChange?.Invoke(this, new EventArgs());
                }
                else
                {
                    currentText = inputText;
                }

                if (JustPressed(Keys.Tab))
                {
                    if (unfocusOnTab)
                    {
                        focused = false;
                        OnUnfocus?.Invoke(this, new EventArgs());
                    }

                    OnTab?.Invoke(this, new EventArgs());
                }

                if (++textBlinkerCount >= 20)
                {
                    textBlinkerState = (textBlinkerState + 1) % 2;
                    textBlinkerCount = 0;
                }
            }

            string text = currentText;

            if (textBlinkerState == 1 && focused)
            {
                text += "|";
            }

            DrawHint(spriteBatch, text);
        }
Exemplo n.º 10
0
        public void Unfocus()
        {
            if (Focused)
            {
                Main.blockInput = false;
                Focused         = false;

                if (Text.Length == 0)
                {
                    TextColor = Color.White;
                    base.SetText(HintText);
                }

                ScaleUpBasedOnHover = true;

                // Keep mouse in interface for 1 frame when we unfocus to prevent player from shooting items
                Player player = Main.player[Main.myPlayer];
                player.mouseInterface = true;

                OnUnfocus?.Invoke();
            }
        }
Exemplo n.º 11
0
 public bool Unfocus()
 {
     OnUnfocus?.Invoke(this);
     return(true);
 }