Quantcast
Viewing all articles
Browse latest Browse all 2010

DEACTIVATE event fires on app load in OS X

When running AIR on OS X (tested with 13.0 on Mavericks), the DEACTIVATE event fires when the application first opens! But this doesn't happen on Windows.

 

So for example:

 

<html>

  <head>

  <title>Simple Test</title>

  </head>

  <body>

  <script src="AIRAliases.js"></script>

  <script>

 

  window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {

 

  air.trace('DEACTIVATE');

 

  });

 

  </script>

  </body>

</html>

 

I will see that trace statement as soon as I run the application... Which is a huge issue as I have logic that I run on DEACTIVATE that I DON'T want to run on app load and in doing so causes a loop of functions 3-4 times... Again this DOES NOT HAPPEN on OS X.

 

Is this a bug? Or am I missing something about the way OS X handles windows?

 

Currently to get around this... I am having to do:

 

if (air.Capabilities.os.indexOf("Mac OS") > -1) {

   

    var firstRun = false;

   

    window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {

 

  if(firstRun) {

 

  air.trace('DEACTIVATE');

 

  } else {

 

  firstRun = true;

  }

 

  });

   

} else {

 

 

  window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {

 

  air.trace('DEACTIVATE');

 

  });

 

}

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 2010

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>