Reactivated and modified text field for keyboard

This commit is contained in:
lukeIam committed 2014-11-09 21:29:15 +01:00
1 parent 5e67d9d4db
commit 9773aa31d8
7 files changed
+65 -11

No files matched your search

+1
View File
@@ -33,6 +33,7 @@ namespace ServerLib
private bool _Encrypted; private bool _Encrypted;
public static SendKeyEventDelegate SendKeyEvent { internal get; set; } public static SendKeyEventDelegate SendKeyEvent { internal get; set; }
public static SendKeyStringEventDelegate SendKeyStringEvent { internal get; set; }
#region profile #region profile
public static GetProfileDataDelegate GetProfileData { internal get; set; } public static GetProfileDataDelegate GetProfileData { internal get; set; }
+17
View File
@@ -58,6 +58,23 @@ namespace ServerLib
CServer.SendKeyEvent(key); CServer.SendKeyEvent(key);
} }
public void SendKeyStringEvent(string keyString)
{
if (!_CheckRight(EUserRights.UseKeyboard))
return;
if (CServer.SendKeyStringEvent == null)
{
if (WebOperationContext.Current != null)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
}
}
else
CServer.SendKeyStringEvent(keyString);
}
#region profile #region profile
public int GetOwnProfileId() public int GetOwnProfileId()
{ {
+1
View File
@@ -26,6 +26,7 @@ using System.Text.RegularExpressions;
namespace ServerLib namespace ServerLib
{ {
public delegate bool SendKeyEventDelegate(string key); public delegate bool SendKeyEventDelegate(string key);
public delegate bool SendKeyStringEventDelegate(string keyString);
#region profile #region profile
public delegate SProfileData GetProfileDataDelegate(int profileId, bool isReadonly); public delegate SProfileData GetProfileDataDelegate(int profileId, bool isReadonly);
+5
View File
@@ -30,6 +30,11 @@ namespace ServerLib
UriTemplate = "/sendKeyEvent?key={key}")] UriTemplate = "/sendKeyEvent?key={key}")]
void SendKeyEvent(string key); void SendKeyEvent(string key);
[OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendKeyStringEvent?keyString={keyString}")]
void SendKeyStringEvent(string keyString);
#region profile #region profile
[OperationContract, WebInvoke(Method = "GET", [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
+26
View File
@@ -64,6 +64,7 @@ namespace Vocaluxe.Base.Server
_Server = new CServer(CConfig.ServerPort, CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON); _Server = new CServer(CConfig.ServerPort, CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON);
CServer.SendKeyEvent = _SendKeyEvent; CServer.SendKeyEvent = _SendKeyEvent;
CServer.SendKeyStringEvent = _sendKeyStringEvent;
CServer.GetProfileData = _GetProfileData; CServer.GetProfileData = _GetProfileData;
CServer.SendProfileData = _SendProfileData; CServer.SendProfileData = _SendProfileData;
CServer.GetProfileList = _GetProfileList; CServer.GetProfileList = _GetProfileList;
@@ -186,6 +187,31 @@ namespace Vocaluxe.Base.Server
return result; return result;
} }
private static bool _sendKeyStringEvent(string keyString)
{
bool result = false;
foreach (var key in keyString.ToCharArray())
{
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, Char.IsUpper(key), false, false, key, _ParseKeys(key)));
result = true;
}
return result;
}
private static Keys _ParseKeys(char keyText)
{
Keys key;
if (!Enum.TryParse(keyText.ToString(), true, out key))
{
key = Keys.None;
}
return key;
}
#region profile #region profile
private static SProfileData _GetProfileData(int profileId, bool isReadonly) private static SProfileData _GetProfileData(int profileId, bool isReadonly)
{ {
+2 -2
View File
@@ -301,10 +301,10 @@
<a data-role="button" id="keyboardButtonP">P</a> <a data-role="button" id="keyboardButtonP">P</a>
</div> </div>
</div> </div>
<!-- <div style> <div>
<label for="keyboardButtonKeys" data-i18n="keyboardButtonKeys"></label> <label for="keyboardButtonKeys" data-i18n="keyboardButtonKeys"></label>
<input type="text" id="keyboardButtonKeys" data-mini="true"> <input type="text" id="keyboardButtonKeys" data-mini="true">
</div> --> </div>
</div> </div>
<!-- /content --> <!-- /content -->
</div> </div>
+13 -9
View File
@@ -693,17 +693,21 @@
}); });
$('#keyboardButtonKeys').keyup(function (e) { $('#keyboardButtonKeys').keyup(function (e) {
var c = String.fromCharCode(e.keyCode); var text = $('#keyboardButtonKeys')[0].value;
if (c.match(/\w/)) {
c = e.keyCode >= 65 ? c.toLowerCase() : c; $('#keyboardButtonKeys')[0].value = "";
if (text.length <= 0) {
return;
}
request({ request({
url: "sendKeyEvent?key=" + c contentType: "application/json;charset=utf-8",
type: "GET",
url: "sendKeyStringEvent?keyString=" + text
}).fail(function () {
$('#keyboardButtonKeys')[0].value = text + $('#keyboardButtonKeys')[0].value;
}); });
}
var oldText = $('#keyboardButtonKeys')[0].value;
if (oldText.length > 0) {
$('#keyboardButtonKeys')[0].value = oldText.slice(1);
}
}); });
}; };