Toolbelt.Blazor.HotKeys2
Toolbelt.Blazor.HotKeys2 copied to clipboard
Example not working
In the old version of HotKeys. I wrote this
HotKeysContext = HotKeys.CreateContext()
.Add(ModKeys.Ctrl, Keys.K, SetFocusInGridSearchField, "Set focus in grid search field");
I tried this in v2, not working
HotKeysContext = HotKeys.CreateContext()
.Add(ModCode.Ctrl,Key.k, SetFocusInGridSearchField, "Set focus in grid search field");
And this not working
HotKeysContext = HotKeys.CreateContext()
.Add(ModCode.Ctrl,Key.k, "Set focus in grid search field", _ => SetFocusInGridSearchField);
Is it because my handler is async?
private async Task SetFocusInGridSearchField()
{
await JsRuntime.InvokeVoidAsync("focusElement", GridSearchBoxPortfolioListGrid);
}
Better headline
@Martin-Andersen Currently, it is intentionally by design.
See also: https://github.com/jsakamoto/Toolbelt.Blazor.HotKeys2/issues/7#issuecomment-1372142048
This also tripped me up a bit as the errors in Visual Studio are not that great.
Would be a great idea to add a note in the sample to the async method exception.
Just a +1 here. Had an async Task method called on button click, tried to wire up a shortcut to call the same method per the sample, it can't resolve the method, and I get a thousand other overload options to scroll through.
My understanding of ValueTask is it's only of performance improvement if the underlyng async operation completes synchronously...They also have a drastically reduced API surface area (by design). See https://devblogs.microsoft.com/dotnet/understanding-the-whys-whats-and-whens-of-valuetask/
Hi everyone,
I've changed my opinion that I don't provide the Add() methods of overloaded version for async Task because so many developers were confused by my decision.
So, the latest preview version of the HotKeys2 now starts to support async Task for its Add() method.
See also: https://www.nuget.org/packages/Toolbelt.Blazor.HotKeys2/3.3.0-preview.1#releasenotes-body-tab