示例#1
0
        public override void Update(float delta)
        {
            if (ContinuousRendering())
            {
                Window.Invalidate();
            }
            var context = WidgetContext.Current;

            // Find the node under mouse, using the render chain built on one frame before.
            context.NodeUnderMouse = LookForNodeUnderMouse(renderChain);

            // Assign NodeCapturedByMouse if any mouse button was pressed.
            var anyCaptureKeyPressed = IsAnyCaptureKeyPressed();

            if (!prevAnyCaptureKeyPressed && anyCaptureKeyPressed)
            {
                context.NodeCapturedByMouse = context.NodeUnderMouse;
            }

            // Process mouse/touch screen input.
            context.GestureManager.Process();

            // Update the widget hierarchy.
            context.MouseCursor = MouseCursor.Default;
            base.Update(delta);
            Window.Cursor = context.MouseCursor;

            // Set NodeCapturedByMouse to null if all mouse buttons were released.
            if (prevAnyCaptureKeyPressed && !anyCaptureKeyPressed)
            {
                context.NodeCapturedByMouse = null;
            }
            prevAnyCaptureKeyPressed = anyCaptureKeyPressed;

            if (Window.Input.WasKeyPressed(Key.DismissSoftKeyboard))
            {
                SetFocus(null);
            }

            // Refresh widgets layout.
            LayoutManager.Layout();

            RaiseUpdating(delta);

            ManageFocusOnWindowActivation();

            // Rebuild the render chain.
            renderChain.Clear();
            renderChain.ClipRegion = new Rectangle(Vector2.Zero, Size);
            RenderChainBuilder?.AddToRenderChain(renderChain);
        }
示例#2
0
        public virtual void Update(float delta)
        {
            if (ContinuousRendering())
            {
                Window.Invalidate();
            }
            var context = WidgetContext.Current;

            // Find the node under mouse, using the render chain built on one frame before.
            context.NodeUnderMouse = LookForNodeUnderMouse(renderChain);

            // Assign NodeCapturedByMouse if any mouse button was pressed or files were dropped.
            var anyCaptureKeyPressed = IsAnyCaptureKeyPressed();

            if (!prevAnyCaptureKeyPressed && anyCaptureKeyPressed || Window.Input.DroppedFiles.Count > 0)
            {
                context.NodeCapturedByMouse = context.NodeUnderMouse;
            }
            else if (
                !anyCaptureKeyPressed ||
                (!(context.NodeCapturedByMouse as Widget)?.GloballyVisible ?? false) ||
                (!(context.NodeCapturedByMouse as Node3D)?.GloballyVisible ?? false)
                )
            {
                // Set NodeCapturedByMouse to null if all mouse buttons are released or widget became invisible.
                context.NodeCapturedByMouse = null;
            }
            prevAnyCaptureKeyPressed = anyCaptureKeyPressed;

            // Update the widget hierarchy.
            context.MouseCursor = MouseCursor.Default;
            Manager.Update(delta);
            Window.Cursor = context.MouseCursor;

            if (Window.Input.WasKeyPressed(Key.DismissSoftKeyboard))
            {
                SetFocus(null);
            }

            ManageFocusOnWindowActivation();

            // Rebuild the render chain.
            renderChain.Clear();
            renderChain.ClipRegion = new Rectangle(Vector2.Zero, Size);
            RenderChainBuilder?.AddToRenderChain(renderChain);
        }