From 765cf16d2f3155f5e3ae71d8dc7a34b34ff17b76 Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Sun, 20 Nov 2016 19:40:33 +0100 Subject: [PATCH] Added KeyDown event to AjaxEditBox --- Site/Controls/v5/Base/AjaxTextBox.ascx | 25 ++++++++++++++++------- Site/Controls/v5/Base/AjaxTextBox.ascx.cs | 1 + Site/Master-v5.master | 9 +++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Site/Controls/v5/Base/AjaxTextBox.ascx b/Site/Controls/v5/Base/AjaxTextBox.ascx index a50d4358..61316c78 100644 --- a/Site/Controls/v5/Base/AjaxTextBox.ascx +++ b/Site/Controls/v5/Base/AjaxTextBox.ascx @@ -8,13 +8,24 @@ $(document).ready(function () { $('#<%=this.TextInput.ClientID%>').keydown(function (e) { - // reset timer if set - if (<%=this.ClientID%>_onChangingTimer != null) { - clearTimeout(<%=this.ClientID%>_onChangingTimer); - <%=this.ClientID%>_onChangingTimer = setTimeout(function() { <%=this.ClientID%>_fireOnChanging(); }, 500); - } else { - // otherwise set new timer with a more generous timeout on keydown in general - <%=this.ClientID%>_onChangingTimer = setTimeout(function () { <%=this.ClientID%>_fireOnChanging(); }, 500); + + if (e.keyCode != 9) { // tab key + + // reset timer if set + if (<%=this.ClientID%>_onChangingTimer != null) { + clearTimeout(<%=this.ClientID%>_onChangingTimer); + <%=this.ClientID%>_onChangingTimer = setTimeout(function() { <%=this.ClientID%>_fireOnChanging(); }, 500); + } else { + // otherwise set new timer with a more generous timeout on keydown in general + <%=this.ClientID%>_onChangingTimer = setTimeout(function() { <%=this.ClientID%>_fireOnChanging(); }, 500); + } + + <% + if (!string.IsNullOrEmpty(this.OnKeyDown)) + { + Response.Write(this.OnKeyDown + "(e.keyCode);"); + } + %> } }); diff --git a/Site/Controls/v5/Base/AjaxTextBox.ascx.cs b/Site/Controls/v5/Base/AjaxTextBox.ascx.cs index fa38f177..6fbcc6a8 100644 --- a/Site/Controls/v5/Base/AjaxTextBox.ascx.cs +++ b/Site/Controls/v5/Base/AjaxTextBox.ascx.cs @@ -30,6 +30,7 @@ namespace Swarmops.Frontend.Controls.Base public string Cookie { set; get; } public string OnChange { get; set; } public string OnChanging { get; set; } + public string OnKeyDown { get; set; } public string AjaxCallbackUrl { set; get; } public TextBoxMode Mode { get; set; } diff --git a/Site/Master-v5.master b/Site/Master-v5.master index acc29edd..c6acafe6 100644 --- a/Site/Master-v5.master +++ b/Site/Master-v5.master @@ -248,7 +248,7 @@

PERSONNAME:

- ​
+ ​