ONE MORE THING!
In my last post I added together the keyCodes, but the OR function isn’t working in java, therefor I separated them.
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | Irodabútor - Térberendező beta28</title>
<link rel="stylesheet" href="TemplateData/style.css">
<link rel="shortcut icon" href="TemplateData/favicon.ico" />
<script src="TemplateData/UnityProgress.js"></script>
<script type="text/javascript">
window.addEventListener('keydown', function (e) {
if (e.keyCode === 8) {
if (e.target === document.body) {
e.preventDefault();
}
}
}, true);
</script>
<script type="text/javascript">
window.addEventListener('keydown', function (e) {
if (e.keyCode === 9) {
if (e.target === document.body) {
e.preventDefault();
}
}
}, true);
</script>
<script type="text/javascript">
window.addEventListener('keydown', function (e) {
if (e.keyCode === 13) {
if (e.target === document.body) {
e.preventDefault();
}
}
}, true);
</script>
</head>
<body class="template">
<p class="header"><span>Unity WebGL Player | </span>Irodabútor - Térberendező beta28</p>
<div class="template-wrap clear">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" height="600px" width="960px"></canvas>
<div class="fullscreen"><img src="TemplateData/fullscreen.png" width="38" height="38" alt="Fullscreen" title="Fullscreen" onclick="SetFullscreen(1);" /></div>
</div>
<p class="footer">« created with <a href="http://unity3d.com/" title="Go to unity3d.com">Unity</a> »</p>
<script type='text/javascript'>
var Module = {
TOTAL_MEMORY: 314572800,
errorhandler: null, // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
compatibilitycheck: null,
dataUrl: "Release/T-WebGL.data",
codeUrl: "Release/T-WebGL.js",
memUrl: "Release/T-WebGL.js.mem",
};
</script>
<script src="Release/UnityLoader.js"></script>
</body>
</html>
Whit this will work ENTER button:
(only for old GUI system)
The “passwordLog” is the last inputField and if you press ENTER, then you can submit.
if (Event.current.isKey && Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl () == "passwordLog")
{
//do something
}
Whit this will work TAB button, only one jump to last inputField.
(only for old GUI system)
GUI.SetNextControlName("loginUsername");
GUI.Label(new Rect(Screen.width/2+50,Screen.height/2-60,220,20),"Felhasználó",LabelBold);
userLog = GUI.TextField (new Rect (Screen.width/2+50, Screen.height/2-40, 220, 30), userLog, 25, inputField);
GUI.SetNextControlName("passwordLog");
if (GUI.GetNameOfFocusedControl () == string.Empty) {
GUI.FocusControl ("userLog");
}
if (Event.current.isKey && Event.current.keyCode == KeyCode.Tab &&
GUI.GetNameOfFocusedControl () == "loginUsername")
{
GUI.FocusControl ("passwordLog");
}
Just try out my project in second comment in any browser.
(In the right circle(BELÉPÉS) is working just now.)