Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 208

qtdeclarative5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>itemCreation.js Example File | Qt QML 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-dynamicscene-example.html">QML Example - Dynamic Scene</a></td><td >itemCreation.js Example File</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtqml-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">itemCreation.js Example File</h1>
<span class="subtitle">dynamicscene/content/itemCreation.js</span>
<!-- $$$dynamicscene/content/itemCreation.js-description -->
<div class="descr"> <a name="details"></a>
<pre class="js">

  var itemComponent = null;
  var draggedItem = null;
  var startingMouse;
  var posnInWindow;

  function startDrag(mouse)
  {
      posnInWindow = paletteItem.mapToItem(window, 0, 0);
      startingMouse = { x: mouse.x, y: mouse.y }
      loadComponent();
  }

  //Creation is split into two functions due to an asynchronous wait while
  //possible external files are loaded.

  function loadComponent() {
      if (itemComponent != null) { // component has been previously loaded
          createItem();
          return;
      }

      itemComponent = Qt.createComponent(paletteItem.componentFile);
      if (itemComponent.status == Component.Loading)  //Depending on the content, it can be ready or error immediately
          component.statusChanged.connect(createItem);
      else
          createItem();
  }

  function createItem() {
      if (itemComponent.status == Component.Ready && draggedItem == null) {
          draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3});
          // make sure created item is above the ground layer
      } else if (itemComponent.status == Component.Error) {
          draggedItem = null;
          console.log("error creating component");
          console.log(itemComponent.errorString());
      }
  }

  function continueDrag(mouse)
  {
      if (draggedItem == null)
          return;

      draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x;
      draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y;
  }

  function endDrag(mouse)
  {
      if (draggedItem == null)
          return;

      if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox
          draggedItem.destroy();
          draggedItem = null;
      } else {
          draggedItem.created = true;
          draggedItem = null;
      }
  }

</pre>
</div>
<!-- @@@dynamicscene/content/itemCreation.js -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>