Skip to content

Instantly share code, notes, and snippets.

@destroytoday
Created December 21, 2010 08:36
Show Gist options
  • Save destroytoday/749666 to your computer and use it in GitHub Desktop.
Save destroytoday/749666 to your computer and use it in GitHub Desktop.
How to unfocus a NativeWindow for unit testing
// At the moment, AIR only has activate() and bringToFront() for focusing windows,
// but it lacks any methods for unfocusing. Though unfocusing a window is a pretty
// rare action, it's necessary for some unit tests. Mine test a minimize menu item
// that is expected to be disabled if no windows are focused. I don't see the AIR
// team adding a deactivate() method, but I do see the possibility of setting
// NativeApplication.nativeApplication.activeWindow to null. Right now, it's read-only.
var window:NativeWindow = NativeApplication.nativeApplication.activeWindow;
window.visible = false;
window.visible = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment