Example #1
0
 internal virtual async Task OnBlurAsync(FocusEventArgs e)
 {
     if (OnBlur.HasDelegate)
     {
         await OnBlur.InvokeAsync(e);
     }
 }
Example #2
0
 private async Task OnBlurAsync(FocusEventArgs e)
 {
     if (OnBlur.HasDelegate)
     {
         await OnBlur.InvokeAsync(e);
     }
 }
Example #3
0
        void OnWindowsEvent(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            if (eventType == WinEvent.EVENT_SYSTEM_MINIMIZEEND || eventType == WinEvent.EVENT_SYSTEM_FOREGROUND)
            {
                FocusedWindow = GetWindowTitle(hwnd);
                if (IsPathOfExileInFocus || IsSidekickInFocus)
                {
                    logger.LogInformation("Path of Exile focused.");
                    PathOfExileWasMinimized = false;
                    OnFocus?.Invoke();
                }
                else if (!PathOfExileWasMinimized)
                {
                    PathOfExileWasMinimized = true;
                    logger.LogInformation("Path of Exile minimized.");
                    OnBlur?.Invoke();
                }

                // If the game is run as administrator, Sidekick also needs administrator privileges.
                if (!PermissionChecked && IsPathOfExileInFocus)
                {
                    PermissionChecked = true;
                    Task.Run(async() =>
                    {
                        if (!IsUserRunAsAdmin() && IsPathOfExileRunAsAdmin())
                        {
                            await RestartAsAdmin();
                        }
                    });
                }
            }
        }
Example #4
0
 public void HandleBlur(string value)
 {
     if (OnBlur.HasDelegate)
     {
         OnBlur.InvokeAsync(value);
     }
 }
Example #5
0
    public void OnDestroy()
    {
        if (OnFocus != null)
        {
            foreach (Delegate d in OnFocus.GetInvocationList())
            {
                OnFocus -= (Action <IDialog>)d;
            }
            OnFocus = null;
        }

        if (OnBlur != null)
        {
            foreach (Delegate d in OnBlur.GetInvocationList())
            {
                OnBlur -= (Action <IDialog>)d;
            }
            OnBlur = null;
        }

        if (OnShow != null)
        {
            foreach (Delegate d in OnShow.GetInvocationList())
            {
                OnShow -= (Action <IDialog>)d;
            }
            OnShow = null;
        }

        if (OnHide != null)
        {
            foreach (Delegate d in OnHide.GetInvocationList())
            {
                OnHide -= (Action <IDialog>)d;
            }
            OnHide = null;
        }

        if (OnClose != null)
        {
            foreach (Delegate d in OnClose.GetInvocationList())
            {
                OnClose -= (Action <IDialog>)d;
            }
            OnClose = null;
        }

        if (OnCancel != null)
        {
            foreach (Delegate d in OnCancel.GetInvocationList())
            {
                OnCancel -= (Action <IDialog>)d;
            }
            OnCancel = null;
        }
    }
Example #6
0
 protected void OnBlurEvent(FocusEventArgs?e)
 {
     if (ValidateOnBlur && EditContext != null)
     {
         EditContext.NotifyFieldChanged(FieldIdentifier);
     }
     if (OnBlur.HasDelegate)
     {
         OnBlur.InvokeAsync(e);
     }
 }
Example #7
0
        private void OnInputBlur()
        {
            if (_isOnOptions)
            {
                return;
            }

            ToggleState = false;

            if (!string.IsNullOrWhiteSpace(Value))
            {
                OnBlur?.Invoke(Value);
            }
        }
Example #8
0
        internal virtual async Task OnBlurAsync(FocusEventArgs e)
        {
            if (_compositionInputting)
            {
                _compositionInputting = false;
            }

            await ChangeValue();

            if (OnBlur.HasDelegate)
            {
                await OnBlur.InvokeAsync(e);
            }
        }
        internal async void Onblur(FocusEventArgs args)
        {
            if (args == null)
            {
                return;
            }
            Focused = false;
            if (OnBlur.HasDelegate)
            {
                await OnBlur.InvokeAsync(args);
            }
            await JsInvokeAsync(JSInteropConstants.blur, Ref);

            StateHasChanged();
        }
Example #10
0
        internal virtual async Task OnBlurAsync(FocusEventArgs e)
        {
            IsFocused = false;
            if (_hasAffixWrapper)
            {
                SetClasses();
            }
            if (_compositionInputting)
            {
                _compositionInputting = false;
            }

            await ChangeValue(true);

            if (OnBlur.HasDelegate)
            {
                await OnBlur.InvokeAsync(e);
            }
        }
Example #11
0
 protected virtual Task HandleBlur(FocusEventArgs args)
 {
     return(OnBlur.InvokeAsync(args));
 }
Example #12
0
        /// <inheritdoc />
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            // Label
            BuildRenderTreeLabel(builder);

            if (HasInputGroup)
            {
                // <div>
                builder.OpenElement(0, Html.DIV);
                builder.AddAttribute(1, Html.CLASS, Bootstrap.INPUT_GROUP);
            }

            if (HasPrepend)
            {
                // <div>
                builder.OpenElement(2, Html.DIV);
                builder.AddAttribute(3, Html.CLASS, Bootstrap.INPUT_GROUP_PREPEND);

                // <span>
                builder.OpenElement(4, Html.SPAN);
                builder.AddAttribute(5, Html.CLASS, Bootstrap.INPUT_GROUP_TEXT);
                builder.AddContent(6, Prepend);
                builder.CloseElement();
                // </span>

                // </div>
                builder.CloseElement();
            }

            // Input
            builder.OpenElement(7, Html.INPUT);
            builder.AddMultipleAttributes(8, Attributes);
            builder.AddAttribute(9, Html.TYPE, "number");
            builder.AddAttribute(10, Html.VALUE, BindConverter.FormatValue(CurrentValueAsString));
            builder.AddAttribute(11, Html.CLASS, CssClass);             // Overwrite class in Attributes

            // Data Binding & OnChange
            builder.AddAttribute(12, Html.ONCHANGE, EventCallback.Factory.CreateBinder <string>(this, async(__value) =>
            {
                // Bind
                CurrentValueAsString = __value;

                // OnChange
                if (OnChange.HasDelegate)
                {
                    await OnChange.InvokeAsync(new ChangeEventArgs {
                        Value = __value
                    });
                }
            }, CurrentValueAsString));

            // OnBlur
            if (OnBlur.HasDelegate)
            {
                builder.AddAttribute(13, "onblur", EventCallback.Factory.Create(this, async(__value) =>
                {
                    await OnBlur.InvokeAsync(new EventArgs());
                }));
            }

            // OnFocus
            if (OnFocus.HasDelegate)
            {
                builder.AddAttribute(13, "onfocus", EventCallback.Factory.Create(this, async(__value) =>
                {
                    await OnFocus.InvokeAsync(new EventArgs());
                }));
            }

            // Disabled?
            if (Disabled ?? false)
            {
                builder.AddAttribute(20, Html.DISABLED, string.Empty);
            }

            // Help
            if (HasHelp)
            {
                builder.AddAttribute(21, Html.ARIA_DESCRIBEDBY, $"{Id}-help");
            }

            builder.CloseElement();

            if (HasAppend)
            {
                // <div>
                builder.OpenElement(22, Html.DIV);
                builder.AddAttribute(23, Html.CLASS, "input-group-append");

                // <span>
                builder.OpenElement(24, Html.SPAN);
                builder.AddAttribute(25, Html.CLASS, Bootstrap.INPUT_GROUP_TEXT);
                builder.AddContent(26, Append);
                builder.CloseElement();
                // </span>

                // </div>
                builder.CloseElement();
            }

            if (HasInputGroup)
            {
                // </div>
                builder.CloseElement();
            }

            // Help
            BuildRenderTreeHelp(builder);
        }
 private async Task OnOptionBlur(FocusEventArgs focusEventArgs)
 {
     await OnBlur.InvokeAsync(new ChoiceGroupOptionFocusEventArgs { Item = Item, FocusEventArgs = focusEventArgs });
 }
Example #14
0
 public static void OnBlurHook()
 {
     OnBlur?.Invoke(null, EventArgs.Empty);
 }
Example #15
0
 private void Blur(FocusEventArgs e)
 {
     this._isFocused = false;
     OnBlur.InvokeAsync(e);
 }
Example #16
0
 protected virtual void OnBlurred(FocusEventArgs obj)
 {
     _isFocused = false;
     Touched    = true;
     BeginValidateAfter(OnBlur.InvokeAsync(obj));
 }
        private async Task HasLostFocus()
        {
            var data = await JsModule.InvokeAsync <string>("GetNumericTextBoxValue", new string[] { "#" + Id });

            var cleaned = string.Join("",
                                      data.Replace("(", "-").Where(x => char.IsDigit(x) ||
                                                                   x == '-' ||
                                                                   x.ToString() == DecimalSeparator).ToArray());
            var parsed = decimal.TryParse(cleaned, NumberStyles.Any, Culture.NumberFormat, out var valueAsDecimal);

            if (!parsed)
            {
                if (string.IsNullOrEmpty(Format))
                {
                    VisibleValue = "";
                }
                else
                {
                    VisibleValue = 0.ToString(Format);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(Format))
                {
                    VisibleValue = cleaned;
                }
                else
                {
                    VisibleValue = valueAsDecimal.ToString(Format);
                }
            }

            // Negative monetary values a represented with parenthesis
            cleaned = string.Join("",
                                  VisibleValue.Replace("(", "-")
                                  .Where(x => char.IsDigit(x) ||
                                         x == '-' ||
                                         x.ToString() == DecimalSeparator).ToArray());

            parsed = decimal.TryParse(cleaned, NumberStyles.Any, Culture.NumberFormat, out var roundedValue);

            if (parsed)
            {
                Value = (TItem)Convert.ChangeType(roundedValue, typeof(TItem));
            }
            else
            {
                Value = (TItem)Convert.ChangeType(valueAsDecimal, typeof(TItem));
            }

            // Do not remove. Problems in browser events and Blazor changes the value of the Value property
            var value = Value;

            await SetVisibleValue(Value);

            Value = value;
            await ValueChanged.InvokeAsync(Value);

            if (!PreviousValue.Equals(Value))
            {
                if (!string.IsNullOrEmpty(FieldIdentifier.FieldName))
                {
                    EditContext.NotifyFieldChanged(FieldIdentifier);
                }
                await NumberChanged.InvokeAsync(Value);
            }

            AdditionalStyles = AlignToRight;

            if (OnBlur != null)
            {
                await OnBlur.Invoke();
            }
        }