Ejemplo n.º 1
0
        public void Reset()
        {
            currentcd = FileExplorer.DesktopPath;
            Text      = "Console - Path: " + currentcd;
            Clear();
            WriteLine("Commands: [clear, toggle bodyoverlay, cd, dir, createfile, deletefile, createdir]");

            CommandInput.Focus();
        }
Ejemplo n.º 2
0
        protected override void Initialise()
        {
            CommandPanel = new HTMLDivElement();
            CommandPanel.Style.BackgroundColor = "black";
            CommandPanel.Style.Overflow        = Overflow.Auto;

            CommandPanel.AddEventListener(EventType.MouseMove, (ev) => {
                CommandPanel.Style.Cursor = Cursor.Text;
                ev.StopPropagation();
            });

            CommandLines = new List <HTMLSpanElement>();

            FillControlWithParent(CommandPanel, 2, 2);

            CommandInput = new HTMLInputElement()
            {
                Type = InputType.Text
            };

            FillHorizontalControlWithParent(CommandInput, 2);

            SetCommandLineElement(CommandInput);

            CommandInput.AddEventListener(EventType.KeyDown, (ev) => {
                var kev = ev.As <KeyboardEvent>();

                if (kev.KeyCode == 13)
                {
                    IncrementLine();
                }
            });

            IncrementLine();

            CommandPanel.AppendChild(CommandInput);

            CommandPanel.AddEventListener(EventType.Click, (ev) => {
                CommandInput.Focus();
            });

            Body.AppendChild(CommandPanel);

            Width  = "677px";
            Height = "392px";
        }
Ejemplo n.º 3
0
        public AutocompleteDropdown(
            string label,
            TextType textType = TextType.TreatAsText,
            int delayMilisec  = Magics.AutocompleteDefaultDelay)
        {
            _cnt.ClassName = GetType().FullNameWithoutGenerics();

            var lbl = new HTMLLabelElement {
                HtmlFor = _input.Id, TextContent = label
            };

            _cnt.AppendChild(lbl);

            _cnt.AppendChild(_input);
            _cnt.AppendChild(_options);
            HideOptions();

            DocumentUtil.AddMouseDownListener(_cnt, x => {
                if (!x.HasHtmlTarget())
                {
                    return;
                }
                var htmlTarget = x.HtmlTarget();

                if (htmlTarget.IsElementOrItsDescendant(_cnt))
                {
                    //clicked inside control (focus stays within logical control) thus do nothing
                    return;
                }

                HideOptions();
            });

            _input.OnFocus += ev => {
                if (_ignoreNextFocus)
                {
                    _ignoreNextFocus = false;
                    return;
                }

                ShowOptions();

                if (!_input.HasFocus())
                {
                    //non user generated (isTrusted == false) events don't invoke default action in Chrome
                    _ignoreNextFocus = true;
                    _input.Focus();
                }
            };
            _input.OnKeyDown += ev => {
                switch (ev.KeyCode)
                {
                case Magics.KeyCodeEscape:
                    if (OptionsVisible)
                    {
                        ev.PreventDefault();
                        ev.StopPropagation();
                        HideOptions();
                    }
                    break;

                case Magics.KeyCodeEnter:
                case Magics.KeyCodeArrowUp:
                case Magics.KeyCodeArrowDown:
                    ev.PreventDefault();
                    OnKeyboardEvent(AutocompleteSrcType.KeyDown, ev);
                    break;

                case Magics.KeyCodeBackspace:
                    OnKeyboardEvent(AutocompleteSrcType.KeyDown, ev);     //it is not called onkeypress
                    break;

                case Magics.KeyCodeTab:
                    HideOptions();
                    break;

                default: break;
                }
            };
            _input.OnKeyPress += ev => {
                switch (ev.KeyCode)
                {
                case Magics.KeyCodeBackspace:
                case Magics.KeyCodeEnter:
                case Magics.KeyCodeArrowUp:
                case Magics.KeyCodeArrowDown:
                    ev.PreventDefault();
                    break;

                default:
                    OnKeyboardEvent(AutocompleteSrcType.KeyPressed, ev);
                    break;
                }
            };

            _textType     = textType;
            _delayMilisec = delayMilisec;
        }