Exemple #1
0
        public KeyInfo ReadKey(bool echo)
        {
            if (dirty)
            {
                Refresh();
            }

            while (true)
            {
                var info = ParentControl.ReadKey();
                if (info == null)
                {
                    continue;
                }

                object handler;
                if (scrollHandlers.TryGetValue(info.KeyData, out handler))
                {
                    if (handler is ScrollHandler)
                    {
                        var handled = ((ScrollHandler)handler)();
                        if (handled)
                        {
                            continue;
                        }
                    }
                    else if (handler is MouseHandler)
                    {
                        var handled = ((MouseHandler)handler)(info.MouseCol, info.MouseRow, info.MouseWheel);
                        if (handled)
                        {
                            continue;
                        }
                    }
                }

                if (echo && info.KeyChar != 0)
                {
                    ScrollIntoView(false);
                    Write(info.KeyChar);
                    return(info);
                }
                else
                {
                    return(info);
                }
            }
        }