Example #1
0
        public override void Update()
        {
            base.Update();

            if (IsMouseHoveringOver)
            {
                if (Text.Length > 0)
                {
                    if (InputTracker.GetKeyDown(Veldrid.Key.BackSpace))
                    {
                        if (CursorIndex > 0)
                        {
                            if (CursorIndex == Text.Length)
                            {
                                Text = Text.Substring(0, Text.Length - 1);
                            }
                            else
                            {
                                var restOfLine = Text.Substring(CursorIndex, (Text.Length - CursorIndex));
                                Text = Text.Substring(0, CursorIndex - 1) + restOfLine;
                            }
                            Label.Content = Text;
                            Label.Recreate();
                            CursorIndex--;
                            CursorControl.Position = GetTextIndexPosition(CursorIndex);
                        }
                    }
                    else if (InputTracker.GetKeyDown(Veldrid.Key.Delete))
                    {
                        if (CursorIndex < Text.Length)
                        {
                            var startLine = Text.Substring(0, CursorIndex);
                            Text          = startLine + Text.Substring(CursorIndex + 1, (Text.Length - CursorIndex) - 1);
                            Label.Content = Text;
                            Label.Recreate();
                        }
                    }
                }

                foreach (var k in InputTracker._newKeysThisFrame)
                {
                    if (KeyHelper.IsInputKey(k))
                    {
                        InsertTextAtCursor(KeyHelper.GetKey(k).ToString());
                    }
                }
            }
        }
Example #2
0
        public override void Update()
        {
            base.Update();

            var mousePos = InputTracker.MousePosition;

            if (mousePos.X >= AbsolutePosition.X && mousePos.X < AbsolutePosition.X + Size.X &&
                mousePos.Y >= AbsolutePosition.Y && mousePos.Y < AbsolutePosition.Y + Size.Y)
            {
                IsMouseHoveringOver = true;
            }
            else
            {
                IsMouseHoveringOver = false;
            }


            if (IsMouseHoveringOver)
            {
                if (InputTracker.GetMouseButtonDown(global::Veldrid.MouseButton.Left))
                {
                    OnMouseDown();
                }
                if (InputTracker.GetMouseButton(Veldrid.MouseButton.Left))
                {
                    IsMouseDown = true;
                    if (IsClickable)
                    {
                        State = ControlState.Clicked;
                    }
                }
                else
                {
                    if (IsMouseDown)
                    {
                        OnMouseUp();
                        IsMouseDown = false;
                    }

                    if (!IsToggled)
                    {
                        if (IsHoverable)
                        {
                            State = ControlState.Hover;
                        }
                        else
                        {
                            State = ControlState.Normal;
                        }
                    }
                }
            }
            else
            {
                if (!IsToggled)
                {
                    State = ControlState.Normal;
                }
                IsMouseDown = false;
            }
        }
Example #3
0
        public void Update(InputSnapshot snap)
        {
            InputTracker.UpdateFrameInput(snap);

            SceneGraph.Update();
        }