Beispiel #1
0
        /// <summary>
        /// Overrides KeyDown event, intercepts Arrow Up/Down and uses them to add/substract the value manually by the step value.
        /// Relying on the browser mean the steps are each integer multiple from <see cref="Min"/> up until <see cref="Max"/>.
        /// This align the behaviour with the spinner buttons.
        /// </summary>
        /// <remarks>https://try.mudblazor.com/snippet/QamlkdvmBtrsuEtb</remarks>
        protected async Task InterceptArrowKey(KeyboardEventArgs obj)
        {
            if (obj.Type == "keydown")//KeyDown or repeat, blazor never fire InvokeKeyPress
            {
                if (obj.Key == "ArrowUp")
                {
                    await Increment();

                    return;
                }
                else if (obj.Key == "ArrowDown")
                {
                    await Decrement();

                    return;
                }
            }
            _keyDownPreventDefault = KeyDownPreventDefault;
            OnKeyPress.InvokeAsync(obj).AndForget();
        }