sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    "Enter" key is not working in SU WebDialogs. Bug?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 244 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fuzzybroF Offline
      fuzzybro
      last edited by

      Hello,

      I've encountered a problem while making a GUI for a SketchUp plugin. I need to get an input confirmation from the user by pressing "Enter key", but I have found out that no KeyDown event is firing in SketchUp WebDialogs, but it is firing in a regular browser (IE/Chrome/Firefox)

      the simple code if here:

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml;lang="en">
        <head>
          <meta http-equiv="content-type" content="text/html; charset=utf-8" />
          <!--<meta http-equiv="X-UA-Compatible" content="EmulateIE8"> -->
          <title>Test Window</title>
      
          <script type="text/javascript">
      
            document.onkeypress = function (e) { 
              e = e || window.event; 
              var charCode = e.charCode || e.keyCode;
              if(charCode == 13) {
                alert("key pressed");
              }			  
          };		
          </script>
      
        </head>
        <body>
        </body>
      </html>
      

      Is it a common thing or I'm the only one who is getting the restriction?
      I've checked this behaviour in SketchUp 8 and 2013 on Win7 and Win8 and have got consistent results.
      How WebDialog web browser is different from regular IE on the system?

      [OctaneRender for SketchUp Overview and Demo Version(http://sketchucation.com/click.php?url)]

      Latest updates, tutorials and artwork
      facebook.com/octane4sketchup

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        No 'key-presses' get processed BUT using document.onkeydown instead will work - so change it.
        To see what's happening temporarily replace
        if(charCode == 13) { alert("key pressed"); }
        with just
        alert(charCode);
        You'll see the number of each key-down you do - '13' is Enter...

        TIG

        1 Reply Last reply Reply Quote 0
        • tt_suT Offline
          tt_su
          last edited by

          I always recommend that people use a JS framework to take care of the compatibility issues - leaving you to interact with a unified API. My personal preference is jQuery.

          I used that in SKUI where I capture ESC and Enter: https://github.com/thomthom/SKUI/blob/master/src/SKUI/js/ui.window.js#L21

          1 Reply Last reply Reply Quote 0
          • fuzzybroF Offline
            fuzzybro
            last edited by

            Ah, so simple 😳
            Thank you guys!

            [OctaneRender for SketchUp Overview and Demo Version(http://sketchucation.com/click.php?url)]

            Latest updates, tutorials and artwork
            facebook.com/octane4sketchup

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement