示例#1
0
文件: Frame.cs 项目: mildsauce45/UPF
        private void CheckInput()
        {
            // We want to enumerate fully here because some of the key presses below can modify the structure
            // of the visual tree and we don't want there to be exceptions
            var castControls = controls.ToList();

            // We're going to tunnel through each control in the frame and inform them of any key events
            // There are three events we're concerned with, KeyDown, KeyPressed, KeyReleased
            /// TODO: Find a better way to traverse the tree, probably caching the tree as flat list
            foreach (var key in inputManager.allKeys)
            {
                if (inputManager.KeyDown(key))
                {
                    VisualTreeHelper.FireKeyDown(key, castControls);
                }

                if (inputManager.KeyPressed(key))
                {
                    VisualTreeHelper.FireKeyPressed(key, castControls);
                }

                if (inputManager.KeyReleased(key))
                {
                    VisualTreeHelper.FireKeyReleased(key, castControls);
                }
            }
        }