Commits

Sebastien Mondet committed 839d869

webpdb: improve download-box

  • Participants
  • Parent commits 80c5353

Comments (0)

Files changed (1)

       (fun () -> failwith "no interaction div")  in
   let input_url =
     Dom_html.createInput ~_type:(string "text") Dom_html.document in
+  let load_scene () =
+    Lwt.ignore_result begin
+      Renderer.load_scene ~renderer []
+      >>= fun () ->
+      fetch_model (to_string input_url##value)
+      >|= PDB.to_scene
+      >>= fun scene ->
+      Renderer.load_scene ~renderer scene
+    end;
+  in
   input_url##value <- string default_model;
   input_url##size <- 50;
-  let go_button =
-    Dom_html.createSpan Dom_html.document in
+  input_url##onkeyup <- Dom_html.handler begin fun ev ->
+      if ev##keyCode = 13 then (
+        debug "Go: %s" (to_string input_url##value);
+        load_scene ();
+      );
+      Js._true
+    end;
+  let go_button = Dom_html.createButton Dom_html.document in
   go_button##innerHTML <- string "Go !";
   go_button##style##color <- string "#f00";
   go_button##onclick <- Dom_html.handler begin fun _ ->
       debug "Go: %s" (to_string input_url##value);
-      Lwt.ignore_result begin
-        Renderer.load_scene ~renderer []
-        >>= fun () ->
-        fetch_model (to_string input_url##value)
-        >|= PDB.to_scene
-        >>= fun scene ->
-        Renderer.load_scene ~renderer scene
-      end;
+      load_scene ();
       Js._true
     end;
   Dom.appendChild interaction_div input_url;