title: QML Popup: know how it was closed
body: <p>I've a QML Popup that I can close by clicking outside of it or by pressing escape (hence default closing policy is fine).
  However, I need to do different things if the popup is closed with escape (cancel a few things) or by clicking outside (commit the changes). I can't use Dialog, we don't want explicit buttons.</p>
  
  <p>How can I reliably detect it ? So far, I've used a MouseArea to detect if the mouse is hover the Popup when it closes. The only issue is that is doesn't work if the user presses escape and it's mouse is outside the popup.</p>
  
  <pre><code>Popup
      {
          onAboutToHide: {
              if(!ma.containsMouse)
              {
  
              }
          }
          contentItem: Text{
                 text: "hello"
          }
  
          MouseArea{
              z:-1
              id: ma
              anchors.fill: parent
              hoverEnabled:true
          }
    }
  </code></pre>
  
  <p>I tried to add </p>
  
  <pre><code>Keys.onEscapePressed:{
   console.log('esc !')
  }
  </code></pre>
  
  <p>to the popup, but then QML complains it's not an item.</p>