Skip to main content
Known Participant
June 18, 2014
Question

DEACTIVATE event fires on app load in OS X

  • June 18, 2014
  • 0 replies
  • 187 views

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');

  });

}

This topic has been closed for replies.