Re: "set bounds" and unexpected vertical offset
Re: "set bounds" and unexpected vertical offset
- Subject: Re: "set bounds" and unexpected vertical offset
- From: Bill Briggs <email@hidden>
- Date: Mon, 16 Jul 2007 21:42:30 -0300
At 5:56 PM -0600 7/16/07, Tom Harrington wrote:
>I'm seeing some strange behavior in a script which I've reduced to the
>following demo code:
>
>tell application "TextEdit"
> activate
> set targetBounds to bounds of window index 1
>end tell
>tell application "Terminal"
> activate
> set bounds of window index 1 to targetBounds
> get bounds of window index 1
>end tell
>
>What this should do is get the bounds of a TextEdit window, and set
>the bounds of a Terminal window to be the same.
>
>This works fine-- on a system with only one display, or on the primary
>display of a multi-display system.
>
>If I move the TextEdit window to a secondary display, the Terminal
>window will not be at the correct location after setting its bounds.
>Instead it will be offset vertically, by a distance equal to the
>difference in pixel heights between the secondary and primary
>displays. For example if the primary display is 1024 pixels high and
>the secondary is 900 pixels high, the Terminal window will be offset
>by 124 pixels from the TextEdit window. If the displays are the same
>height then there's no difference.
>
>In some cases-- and I haven't been able to work out exactly when-- the
>bug only manifests in the above code if the "set bounds" statement is
>executed twice (i.e. just duplicate that line). In my actual code
>this isn't necessary, though.
>
>Why would I get different behavior depending on the locations of the
>windows? I've checked this on a couple of different Macs (both PPC
>and Intel) with the same results.
If you have two monitors that are different pixel heights, how are they aligned when you look at the Displays Preference Panel? And does that make any difference?
There is one aspect of setting the bounds of Terminal windows that is different from "normal" application windows. Terminal sizes windows based on the number of characters wide and the number of lines deep. If you try to set bounds that would result in a width that isn't an exact number of characters, it will be set a bit higher or lower to make it exact. Same with lines in the depth. You can't have a terminal window that cuts off half a character or half a line. So the setting of bounds with AppleScript and Terminal windows is different.
I didn't check your situation with a second monitor (I'd have to get up, walk four feet and plug in a second monitor), but first thing I'd do is see how the monitor alignment was set up and whether that made any difference.
- web
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden