public void Show(Vector2d position, Action callback)
        {
            DivElement simpleInputElement = Document.GetElementById <DivElement>("simpleinput");
            DivElement modalElement       = Document.GetElementById <DivElement>("simplemodal");

            modalElement.Style.Display          = "block";
            simpleInputElement.Style.Display    = "block";
            simpleInputElement.Style.MarginLeft = position.X.ToString() + "px";
            simpleInputElement.Style.MarginTop  = position.Y.ToString() + "px";

            textElement       = Document.GetElementById <SelectElement>("inputtext");
            textElement.Value = Text;

            DivElement titleDiv = Document.GetElementById <DivElement>("simpletitle");
            DivElement labelDiv = Document.GetElementById <DivElement>("inputlabel");

            titleDiv.InnerText = Title;
            labelDiv.InnerText = Label;



            textElement.AddEventListener("change", TextChanged, false);
            textElement.AddEventListener("click", IgnoreMe, true);

            //Window.AddEventListener("click", NonMenuClick, true);

            AnchorElement okButton     = Document.GetElementById <AnchorElement>("simpleinputok");
            AnchorElement cancelButton = Document.GetElementById <AnchorElement>("simpleinputcancel");

            okButton.AddEventListener("click", OkClicked, false);
            cancelButton.AddEventListener("click", CancelClicked, false);
            okCallback = callback;
        }
Пример #2
0
 public ValueBinder(InputElement target, Expression expression)
     : base(target, "value", expression)
 {
     _target         = target;
     _changeListener = OnChanged;
     target.AddEventListener("change", _changeListener, false);
 }
Пример #3
0
        protected override Element CreateNode()
        {
            var contentContainer = Browser.Document.CreateElement("table");

            contentContainer.Style.Width = "100%";

            contentContainerRow = Browser.Document.CreateElement("tr");
            contentContainer.AppendChild(contentContainerRow);

//            contentContainer.Style.Height = "100%";

            contentNodeCell             = Browser.Document.CreateElement("td");
            contentNodeCell.Style.Width = "100%";
            contentContainerRow.AppendChild(contentNodeCell);

            var contentNodeCellDiv = Browser.Document.CreateElement("div");

            contentNodeCellDiv.Style.Height = "100%";
            contentNodeCellDiv.Style.Width  = "100%";
            contentNodeCell.AppendChild(contentNodeCellDiv);

            var loadingIconCell = Browser.Document.CreateElement("td");

            loadingIconCell.AppendChild(loadingIcon.Node);
            loadingIconCell.SetAttribute("align", "center");
            loadingIconCell.Style.VerticalAlign = "middle";
            loadingIconCell.Style.LineHeight    = ".1";
            loadingIconCell.Style.PaddingRight  = "2px";
            contentContainerRow.AppendChild(loadingIconCell);

            contentNode = Browser.Document.CreateElement("input").As <InputElement>();
            contentNode.SetAttribute("type", "text");
            contentNode.Style.Border      = "0px black solid";
            contentNode.Style.Height      = "100%";
            contentNode.Style.Width       = "100%";
            contentNode.Style.PaddingLeft = "5px";
            contentNode.Style.Outline     = "none";
            contentNode.AddEventListener("keydown", OnKeyDown);
            contentNode.AddEventListener("keypress", OnKeyPress);
            contentNode.AddEventListener("blur", OnBlur);
            contentNodeCellDiv.AppendChild(contentNode);

            overlayContainer = Browser.Document.CreateElement("div");
            overlayContainer.Style.Position = "absolute";
            overlayContainer.Style.Display  = "none";
            overlayContainer.AppendChild(overlay.Node);

            // This prevents mouse events from forcing an onblur on the input control.  Basically,
            // we prevent the mousedown from propagating to the input control and so it cannot
            // recognize the loss of focus.
            overlayContainer.AddEventListener("mousedown", e =>
            {
                e.StopImmediatePropagation();
                e.PreventDefault();
            });
            overlayContainer.AddEventListener("focus", e => Console.WriteLine("focus"));

            var overlayAnchor = Browser.Document.CreateElement("div");

            overlayAnchor.Style.Position = "relative";
            overlayAnchor.AppendChild(overlayContainer);

            var result = Browser.Document.CreateElement("div");

            result.Style.Border = "1px solid #999";
            result.AppendChild(contentContainer);
            result.AppendChild(overlayAnchor);
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Create various events that tie the functionality of the spreadsheet
        /// </summary>
        /// <param name="input">Input element to attach events to</param>
        private void AttachEvents(InputElement input)
        {
            input.AddEventListener("blur", delegate(ElementEvent @event)
            {
                GetRowHeader(@event.SrcElement).ClassList.Remove("selected");
                GetColumnHeader(@event.SrcElement).ClassList.Remove("selected");

                ProcessCell((InputElement)@event.SrcElement);
            }, false);

            input.AddEventListener("focus", delegate(ElementEvent @event)
            {
                GetRowHeader(@event.SrcElement).ClassList.Add("selected");
                GetColumnHeader(@event.SrcElement).ClassList.Add("selected");

                object formula = @event.SrcElement.GetAttribute("data-formula");

                if (formula != null && formula.ToString().Length > 1)
                {
                    input.Value = formula.ToString();
                }
            }, false);

            input.AddEventListener("keydown", delegate(ElementEvent @event)
            {
                if (@event.KeyCode == 27) //Escape
                {
                    input.Value = "";
                    input.Blur();
                }
                else if (@event.KeyCode == 38) // up arrow
                {
                    SetFocusFromCellTo(@event.SrcElement.ID, 0, -1);
                    @event.PreventDefault();
                }
                else if (@event.KeyCode == 40) // down arrow
                {
                    SetFocusFromCellTo(@event.SrcElement.ID, 0, 1);
                    @event.PreventDefault();
                }
                else if (@event.KeyCode == 37) // left arrow
                {
                    SetFocusFromCellTo(@event.SrcElement.ID, -1, 0);
                    @event.PreventDefault();
                }
                else if (@event.KeyCode == 39) // right arrow
                {
                    SetFocusFromCellTo(@event.SrcElement.ID, 1, 0);
                    @event.PreventDefault();
                }
            }, true);

            input.AddEventListener("keypress", delegate(ElementEvent @event)
            {
                if (@event.KeyCode == 13) // Enter Key
                {
                    input.Blur();

                    SetFocusFromCellTo(@event.SrcElement.ID, 0, 1);
                    @event.PreventDefault();
                }
            }, false);
        }