This content has been marked as final. Show 3 replies
I have used Buddy API in the past to do this (of course!). Take a look
at baMultiDisplayInfo() - it will tell you which monitor the user has
configured as their "primary"
Thanks Sean, baMultiDisplayInfo is new and somehow I missed the update to one of the most useful xtras out there.
I’m not sure it solves the problem though. Maximizing to the primary monitor is easy, _system.deskTopRectList will give you the proper rect and I guess you could extract the same info from baMultiDisplayInfo. The bigger challenge is to simulate the behavior of the maximize box in the window titlebar, to do this you need to maximize to the “closest” monitor, not necessarily the primary monitor. I thought I would be cleaver and use _movie.stage.maximize() rather than _movie.stage.rect =_system.deskTopRectList to get the stage full screen but to my surprise, _movie.stage.maximize() does not simulate the titlebar box, it always goes for the primary, what’s up with that?!? ;-) … Anyway, I’m sure there’s a way to cycle through the deskTopRectList and assemble some representation of the patchwork of display rectangles, gaps and all, then try to figure out where the stage is among them but I’m not sure it’s worth the effort. Every example I’ve seen simply targets the primary and I guess that’s good enough.
Using the area method wasn’t that tough. The following function will return the index to _system.deskTopRectList containing the greatest amount of projector stage:
myAreaList = 
repeat with myRect in _system.deskTopRectList
myIntersectRect = myRect.intersect(_movie.stage.rect)
myArea = (myIntersectRect.right - myIntersectRect.left) * (myIntersectRect.bottom - myIntersectRect.top)
myMonitor = myAreaList.getOne(myAreaList.max())
So for example, if 30% of your stage is on monitor 1, 45% is on monitor 2, and 25% is off screen, this function will return 2. In most cases users will have the window positioned entirely on one monitor, so if 100% of the stage is on monitor 3, this function will return 3. I don’t know what would happen if you called this function with the projector minimized (that can’t happen with the way my project is set up) but I suspect the function will simply return 0. It may not work exactly like the window titlebar maximize box but it’s better than always using _system.deskTopRectList