Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can clipbnoard be used without lambda function? #1214

Open
andy-burns-uk opened this issue Jan 24, 2023 · 0 comments
Open

Can clipbnoard be used without lambda function? #1214

andy-burns-uk opened this issue Jan 24, 2023 · 0 comments

Comments

@andy-burns-uk
Copy link

In a blazor server app I've tried to use a "normal" function to access the clipboard, instead of the lambda function per your example

@page "/Clipboard"
@using CurrieTechnologies.Razor.Clipboard
@Inject ClipboardService clipboard

cliptest
<button @OnClick="myfunc">myfunc

@code
private async void myfunc(MouseEventArgs e) {
string a = await clipboard.ReadTextAsync();
}

your minified js is included in the page via the _host.cshtml
but I get an exception when I click my button

Exception has occurred: CLR/Microsoft.JSInterop.JSException
Exception thrown: 'Microsoft.JSInterop.JSException' in System.Private.CoreLib.dll:
'Document is not focused.
undefined'
at System.Threading.Tasks.ValueTask1.get_Result() at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__161.MoveNext()
at System.Threading.Tasks.ValueTask`1.get_Result()
at CurrieTechnologies.Razor.Clipboard.ClipboardService.d__4.MoveNext()
at blazorWeb.Pages.Clipboard.d__2.MoveNext() in C:\Data\Dev\MDTinfo3\blazorWeb\Pages\Clipboard.razor:line 32

Is this "document not focused" the reason you had to use a lambda function, or should my code work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant