Пример #1
0
        public Panelhandler(Lib.UserInputManager manager, UserInputKey key, KeyPointAction onOpen, KeyPointAction onClose,
                            bool blockEnv = true)
        {
            var openhandler      = new KeyHandler(Layer.Ui, BlockType.None);
            var closehandler     = new KeyHandler(Layer.Ui, BlockType.All);
            var openBlockhandler = blockEnv ? new PointerKeyHandler(Layer.Ui, BlockType.All) : null;

            openhandler.BindKeyAction(key, (data) =>
            {
                manager.RegisterKeyhandler(closehandler);
                manager.RegisterPointerhandler(openBlockhandler);
                manager.UnregisterKeyhandler(openhandler);
            });

            if (null != onOpen)
            {
                openhandler.BindKeyAction(key, onOpen);
            }

            closehandler.BindKeyAction(key, (data) =>
            {
                manager.RegisterKeyhandler(openhandler);
                manager.UnregisterKeyhandler(closehandler);
                manager.UnregisterPointerhandler(openBlockhandler);
            });
            if (null != onClose)
            {
                closehandler.BindKeyAction(key, onClose);
            }

            manager.RegisterKeyhandler(openhandler);
        }
Пример #2
0
 public void UnblockKey(int key)
 {
     if (_keyDic.ContainsKey(key))
     {
         _avaliableKeys.Enqueue(_keyDic[key]);
         _manager.UnregisterKeyhandler(_keyDic[key].Handler);
     }
 }