« Managing Symbolic Links in AIR | Main | Update on my AIR Applications and Libraries »

January 18, 2008

Converting Stage Coordinates to Screen Coordinates

In the Exchange calendaring application I'm working on (called Lineup), when the user double-clicks on an appointment, I open up an appointment detail window which shows you things like the location, full description, etc. Initially, I was just opening a utility window (a native window with smaller chrome), but after seeing the newest version of iCal, I was inspired to do something more creative. I still open a new window, but it's a customized transparent window which looks more like a dialog bubble extending from the exact point where the user clicked.

In order for the effect to work properly, I needed to place the window at very precise screen coordinates so that the window was clearly associated with the appointment that was clicked on. At first, I tried doing my own coordinate calculations using the stage x/y coordinates of the double click, and the coordinates of the application window. The problem was that I had no way to take native window chrome into account, so although I got it working on Mac, the window placement was off on Windows.

Fortunately, AIR has an API that does the work for you by taking the coordinates from a "local" mouse event (relative to the window stage) and converting them into screen or global coordinates. The function is NativeWindow.globalToScreen(), and it fixed my problem perfectly. Now, Lineup has iCal-like detail windows that appear right where they are supposed to on Mac, Windows, and eventually on Linux, as well.

Posted by cantrell at January 18, 2008 10:12 AM

Comments

Wondering if it works on with multiple monitors too. Will try it at work too.

Adrian.

Posted by: Adrian Aioanei at January 18, 2008 12:00 PM




Remember Me?

(you may use HTML tags for style)

Copyright © 2009 Adobe Systems Incorporated. All rights reserved.
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-14-2009).