Search Unity

Backspace bug again in 5.3 b5!

Discussion in 'Web' started by Slyrfecso1, Nov 8, 2015.

  1. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    Hi,

    (I have posted these in Unity 5.3 beta forum too, sorry for 2x)
    Backspace bug was fixed in 5.1.3, but now it is here again.
    • (700861) - WebGL: Fixed backspace key navigating away from page in Chrome.
    Please fix it in the next beta.

    I have used SetNextControlName for Tab button, but it is working only in Unity editor.
    Please fix it in the next beta.


    I would like to use Enter button in the browsers after I have used the last inputField.
    If it is possible, please fix it.


    Thanks for all.
     
    Last edited: Nov 9, 2015
  2. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    So you can reproduce it with the exact same steps as listed on the report with 5.3b6?
    I tried this just now but can not do it.
     
  3. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    Sorry, but I didn't understand your ask.
    (Where can I find 5.3b6?)
    You can try my project. On the first screen you will land on the login screen.
    (The WebGL page is imported with iframe, but without iframe is the same!)

    http://terberendezo.alexbutor.hu
    user: admin
    pass: designer


    Thanks.
     
  4. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    The b6 build is coming soon. But can you please submit a new bug report with a minimal repro project if possible?
    I think I can see what the issue is on your page but I can't make this happen in a project I made.

    Please ping the case number here after you submitted it.
     
  5. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    I have solved;)

    The problem is I have imported the Unity build index file with iFrame and I added the Event script code to the master page not to the Unity build index file.

    This code is blocking "backspace" and you would stay in your project and if you add script to your inputField than you can use "tab" and "enter" buttons too.
    Code (JavaScript):
    1. <script type="text/javascript">
    2.         window.addEventListener('keydown', function (e) {
    3.             if (e.keyCode === 8 || e.keyCode === 9 || e.keyCode === 13 ) {
    4.                 if (e.target === document.body) {
    5.                     e.preventDefault();
    6.                 }
    7.             }
    8.         }, true);
    9.     </script>

    Here you can see where I pasted this.
    Code (JavaScript):
    1. <!doctype html>
    2. <html lang="en-us">
    3.   <head>
    4.     <meta charset="utf-8">
    5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    6.     <title>Unity WebGL Player | Irodabútor - Térberendező beta28</title>
    7.     <link rel="stylesheet" href="TemplateData/style.css">
    8.     <link rel="shortcut icon" href="TemplateData/favicon.ico" />
    9.     <script src="TemplateData/UnityProgress.js"></script>
    10.  
    11.     <script type="text/javascript">
    12.         window.addEventListener('keydown', function (e) {
    13.             if (e.keyCode === 8 || e.keyCode === 9 || e.keyCode === 13 ) {
    14.                 if (e.target === document.body) {
    15.                     e.preventDefault();
    16.                 }
    17.             }
    18.         }, true);
    19.     </script>
    20.  
    21.   </head>
    22.   <body class="template">
    23.     <p class="header"><span>Unity WebGL Player | </span>Irodabútor - Térberendező beta28</p>
    24.     <div class="template-wrap clear">
    25.       <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" height="600px" width="960px"></canvas>
    26.       <br>
    27.       <div class="fullscreen"><img src="TemplateData/fullscreen.png" width="38" height="38" alt="Fullscreen" title="Fullscreen" onclick="SetFullscreen(1);" /></div>
    28.     </div>
    29.     <p class="footer">&laquo; created with <a href="http://unity3d.com/" title="Go to unity3d.com">Unity</a> &raquo;</p>
    30.     <script type='text/javascript'>
    31.   var Module = {
    32.     TOTAL_MEMORY: 314572800,
    33.     errorhandler: null,            // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    34.     compatibilitycheck: null,
    35.     dataUrl: "Release/T-WebGL.data",
    36.     codeUrl: "Release/T-WebGL.js",
    37.     memUrl: "Release/T-WebGL.js.mem",
    38.   };
    39. </script>
    40. <script src="Release/UnityLoader.js"></script>
    41.  
    42.   </body>
    43. </html>
    44.  

    I hope my solution will help for anyone else.
     
    Last edited: Nov 11, 2015
  6. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    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.

    Code (JavaScript):
    1. <!doctype html>
    2. <html lang="en-us">
    3.   <head>
    4.     <meta charset="utf-8">
    5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    6.     <title>Unity WebGL Player | Irodabútor - Térberendező beta28</title>
    7.     <link rel="stylesheet" href="TemplateData/style.css">
    8.     <link rel="shortcut icon" href="TemplateData/favicon.ico" />
    9.     <script src="TemplateData/UnityProgress.js"></script>
    10.     <script type="text/javascript">
    11.         window.addEventListener('keydown', function (e) {
    12.             if (e.keyCode === 8) {
    13.                 if (e.target === document.body) {
    14.                     e.preventDefault();
    15.                 }
    16.             }
    17.         }, true);
    18.     </script>
    19.     <script type="text/javascript">
    20.         window.addEventListener('keydown', function (e) {
    21.             if (e.keyCode === 9) {
    22.                 if (e.target === document.body) {
    23.                     e.preventDefault();
    24.                 }
    25.             }
    26.         }, true);
    27.     </script>
    28.     <script type="text/javascript">
    29.         window.addEventListener('keydown', function (e) {
    30.             if (e.keyCode === 13) {
    31.                 if (e.target === document.body) {
    32.                     e.preventDefault();
    33.                 }
    34.             }
    35.         }, true);
    36.     </script>
    37.  
    38.  
    39.   </head>
    40.   <body class="template">
    41.     <p class="header"><span>Unity WebGL Player | </span>Irodabútor - Térberendező beta28</p>
    42.     <div class="template-wrap clear">
    43.       <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" height="600px" width="960px"></canvas>
    44.       <br>
    45.       <div class="fullscreen"><img src="TemplateData/fullscreen.png" width="38" height="38" alt="Fullscreen" title="Fullscreen" onclick="SetFullscreen(1);" /></div>
    46.     </div>
    47.     <p class="footer">&laquo; created with <a href="http://unity3d.com/" title="Go to unity3d.com">Unity</a> &raquo;</p>
    48.     <script type='text/javascript'>
    49.   var Module = {
    50.     TOTAL_MEMORY: 314572800,
    51.     errorhandler: null,            // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    52.     compatibilitycheck: null,
    53.     dataUrl: "Release/T-WebGL.data",
    54.     codeUrl: "Release/T-WebGL.js",
    55.     memUrl: "Release/T-WebGL.js.mem",
    56.   };
    57. </script>
    58. <script src="Release/UnityLoader.js"></script>
    59.  
    60.   </body>
    61. </html>
    62.  

    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.
    Code (CSharp):
    1. if (Event.current.isKey && Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl () == "passwordLog")
    2.             {
    3. //do something
    4. }

    Whit this will work TAB button, only one jump to last inputField.
    (only for old GUI system)
    Code (CSharp):
    1. GUI.SetNextControlName("loginUsername");
    2.             GUI.Label(new Rect(Screen.width/2+50,Screen.height/2-60,220,20),"Felhasználó",LabelBold);
    3.             userLog = GUI.TextField (new Rect (Screen.width/2+50, Screen.height/2-40, 220, 30), userLog, 25, inputField);
    4.             GUI.SetNextControlName("passwordLog");
    5.             if (GUI.GetNameOfFocusedControl () == string.Empty) {
    6.                 GUI.FocusControl ("userLog");
    7.             }
    8.  
    9.             if (Event.current.isKey && Event.current.keyCode == KeyCode.Tab &&
    10.                 GUI.GetNameOfFocusedControl () == "loginUsername")
    11.             {
    12.                 GUI.FocusControl ("passwordLog");
    13.             }

    Just try out my project in second comment in any browser.
    (In the right circle(BELÉPÉS) is working just now.)
     
    Last edited: Nov 15, 2015