5 changed files with 39 additions and 15 deletions
@ -0,0 +1,22 @@ |
|||
using Microsoft.AspNetCore.Components; |
|||
|
|||
namespace Avalonia.Web.Blazor.Interop; |
|||
|
|||
internal class FocusHelperInterop |
|||
{ |
|||
private const string FocusSymbol = "FocusHelper.focus"; |
|||
private const string SetCursorSymbol = "FocusHelper.setCursor"; |
|||
|
|||
private readonly AvaloniaModule _module; |
|||
private readonly ElementReference _inputElement; |
|||
|
|||
public FocusHelperInterop(AvaloniaModule module, ElementReference inputElement) |
|||
{ |
|||
_module = module; |
|||
_inputElement = inputElement; |
|||
} |
|||
|
|||
public void Focus() => _module.Invoke(FocusSymbol, _inputElement); |
|||
|
|||
public void SetCursor(string kind) => _module.Invoke(SetCursorSymbol, _inputElement, kind); |
|||
} |
|||
@ -1,5 +1,6 @@ |
|||
export { DpiWatcher } from "./Avalonia/DpiWatcher" |
|||
export { InputHelper } from "./Avalonia/InputHelper" |
|||
export { FocusHelper } from "./Avalonia/FocusHelper" |
|||
export { NativeControlHost } from "./Avalonia/NativeControlHost" |
|||
export { SizeWatcher } from "./Avalonia/SizeWatcher" |
|||
export { SKHtmlCanvas } from "./Avalonia/SKHtmlCanvas" |
|||
|
|||
@ -0,0 +1,9 @@ |
|||
export class FocusHelper { |
|||
public static focus(inputElement: HTMLElement) { |
|||
inputElement.focus(); |
|||
} |
|||
|
|||
public static setCursor(inputElement: HTMLInputElement, kind: string) { |
|||
inputElement.style.cursor = kind; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue