File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
src/BootstrapBlazor/Components/Textarea Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 66{
77 <BootstrapLabel required =" @Required" for =" @Id" ShowLabelTooltip =" ShowLabelTooltip" Value =" @DisplayText" />
88}
9- <textarea @attributes =" AdditionalAttributes" placeholder =" @PlaceHolder" id =" @Id" class =" @ClassName" disabled =" @Disabled" @bind-value =" @CurrentValueAsString" @bind-value:event =" @EventString" @onblur =" OnBlur" data-bb-scroll =" @AutoScrollString" @ref =" FocusElement" ></textarea >
9+ <textarea @attributes =" AdditionalAttributes" placeholder =" @PlaceHolder" id =" @Id" class =" @ClassName" disabled =" @Disabled"
10+ @bind-value =" @CurrentValueAsString" @bind-value:event =" @EventString"
11+ @onkeyup =" OnKeyUp"
12+ @onblur =" OnBlur" data-bb-scroll =" @AutoScrollString" @ref =" FocusElement" ></textarea >
Original file line number Diff line number Diff line change 33// See the LICENSE file in the project root for more information.
44// Maintainer: Argo Zhang([email protected] ) Website: https://www.blazor.zone 55
6+ using Microsoft . AspNetCore . Components . Web ;
7+
68namespace BootstrapBlazor . Components ;
79
810/// <summary>
@@ -34,6 +36,12 @@ public partial class Textarea
3436 [ Parameter ]
3537 public bool IsAutoScroll { get ; set ; }
3638
39+ /// <summary>
40+ /// 获得/设置 文本框按键回调委托方法 默认为 null
41+ /// </summary>
42+ [ Parameter ]
43+ public Func < KeyboardEventArgs , Task > ? OnKeyUpAsync { get ; set ; }
44+
3745 /// <summary>
3846 /// 获得 客户端是否自动滚屏标识
3947 /// </summary>
@@ -53,4 +61,20 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
5361 await InvokeVoidAsync ( "execute" , Id , "update" ) ;
5462 }
5563 }
64+
65+ private async Task OnKeyUp ( KeyboardEventArgs args )
66+ {
67+ if ( args . Key == "Enter" && OnEnterAsync != null )
68+ {
69+ await OnEnterAsync ( Value ) ;
70+ }
71+ if ( args . Key == "Escape" && OnEscAsync != null )
72+ {
73+ await OnEscAsync ( Value ) ;
74+ }
75+ if ( OnKeyUpAsync != null )
76+ {
77+ await OnKeyUpAsync ( args ) ;
78+ }
79+ }
5680}
You can’t perform that action at this time.
0 commit comments